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 2 of 2

Thread: How to execute a Callable Statement

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation How to execute a Callable Statement

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.sql.*;
     
     
    public class JoinTest {
    public static void main(String[] args) {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	try {
    		System.out.println("Enter name of emp");
    		String name=br.readLine();
    		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    		Connection con= DriverManager.getConnection("Jdbc:Odbc:JoinTest","sa","micro123");
    		CallableStatement stmt = con.prepareCall("exec getPhone name");
    		ResultSet rs=stmt.getResultSet();
    		while (rs.next()){
    			String name1=rs.getString(1);
    			int phone=rs.getInt(2);
    			System.out.println(name1+" "+phone);
    		}}
    			 catch (Exception e) {
    		// TODO Auto-generated catch block
    		e.printStackTrace();
    	}
     
     
    }
    }

    Hi friends...
    I am using callable statement first time and not able to run the program.
    When I try to run program, I got "Microsoft][ODBC Driver Manager] Function sequence error"..
    Please tell me the right procedure to use Callable Statement...
    Thanks in advance....


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: How to execute a Callable Statement

    When I try to run program, I got "Microsoft][ODBC Driver Manager] Function sequence error"..
    Paste the exception message here.

Similar Threads

  1. execute bat file with arguments
    By kafka82 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: August 6th, 2011, 01:20 PM
  2. [SOLVED] .jar file won't execute
    By pajfilms in forum What's Wrong With My Code?
    Replies: 27
    Last Post: August 3rd, 2011, 07:43 PM
  3. Could not execute the file
    By miaaa00 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 20th, 2011, 08:28 AM
  4. Code doesn't execute properly
    By fride360 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 12th, 2011, 11:36 AM
  5. unable to execute prepared statement
    By nrao in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 11th, 2010, 07:26 PM