• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Stoared procedure & Type 4 driver

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.sql.*;
class DemoCallable {
public static void main(String a[])
{
try{
Class.forName("oracle.jdbc.driver.OracleDriver");// Type 4 Driver
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@dbs:1521:orcl","scott","tiger");


/*Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // to load Type1 driver
Connection conn=DriverManager.getConnection("jdbc:odbc:mydsn","scott","tiger"); // for connection, mydsn is dsn , java is username, java is password*/


System.out.println("Connection : " + conn);
CallableStatement cstmt = conn.prepareCall(" {call sqr(?, ?)} ");
System.out.println("Callable Statement : " + cstmt);

cstmt.setInt(1,10);

cstmt.registerOutParameter(2,Types.INTEGER);

boolean b=cstmt.execute();

System.out.println(cstmt.getInt(2));

cstmt.close();
conn.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
};

Q )In above code,
If I am using Type 1 driver ,Then its properly working(Return me square of 10)
But when I am using Type4 driver , It will show me Null Pointer Exception.
Why?
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does e.printStackTrace() say ?

Shailesh
 
Danger, 10,000 volts, very electic .... tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic