Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Web Service connectivity

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Web Service connectivity

    Hii,

    I am an query??
    Following is my java code for database coonectivity through web service:
    package net.org;

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.OutputStreamWriter;
    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Properties;


    public class ConnectUpdateAmt {

    int i;

    public String updateBalance(String card1,String balAmt)
    {

    String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=fApplication";
    String user="sa";
    String password="ftl@123";

    try{
    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
    Connection connection = DriverManager.getConnection(connectionUrl,user,pas sword);

    String sql = "{ call dbo.updateBalance(?,?) }";

    CallableStatement cstmt =connection.prepareCall(sql);
    cstmt.setString(1,card1);
    cstmt.setString(3,balAmt);



    i= cstmt.executeUpdate();

    }

    catch(Exception exc){
    System.out.println(exc.getMessage());
    }
    if(i==1)
    {return "Success";}

    else {
    return "unSuccess";}
    }

    }

    And I am using stored procedure for the same through SQL Server,
    My table contains three columns:name,fingerprint and balamt.
    All three are varchar .
    i am using same steps for insert,select.
    but getting error in update.
    Plz help me for the same.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Web Service connectivity

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    getting error in update.
    Please copy the full text of the error message and paste it here. It has important info about the error.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Re: Web Service connectivity

    Quote Originally Posted by Norm View Post
    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.


    Please copy the full text of the error message and paste it here. It has important info about the error.
    There is no error in my code but my database field are not updated.
    I can see no changes in my table column.

  4. #4
    Member
    Join Date
    Oct 2013
    Location
    Manila, Philippines
    Posts
    285
    My Mood
    Amused
    Thanks
    6
    Thanked 64 Times in 61 Posts

    Default Re: Web Service connectivity

    look at this statement in your code: cstmt.setString(3,balAmt);
    that sets the third parameter to balAmt but actually you only have 2 parameters in your stored procedure String sql = "{ call dbo.updateBalance(?,?) }";

  5. #5
    Junior Member
    Join Date
    Feb 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Web Service connectivity

    I have tried this also.
    but still its not working..
    Even tried with
     String SPsql = "EXEC dbo.updateBalance ?,?; 
    		    PreparedStatement ps = connection.prepareStatement(SPsql);	
     
    				ps.setString(1,cardno);
    				ps.setString(2,balAmt);

    need a help for the same....

    --- Update ---

    Hey dude it worked..
    What you have suggeested i have used it and it worked...
    Thanks alot...
    Thank you........

Similar Threads

  1. Web Service for translate
    By mija in forum Java Theory & Questions
    Replies: 0
    Last Post: September 19th, 2012, 01:57 PM
  2. Web service references
    By Eggbert in forum Java IDEs
    Replies: 3
    Last Post: October 25th, 2011, 06:46 AM
  3. web service client
    By maverick257 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 24th, 2010, 03:59 AM
  4. Java web client - > .NET web service
    By codeJ in forum Web Frameworks
    Replies: 0
    Last Post: July 8th, 2010, 04:34 AM
  5. [SOLVED] Web Service from WSDL
    By wilky in forum Java Theory & Questions
    Replies: 3
    Last Post: January 25th, 2010, 10:45 AM