File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to connect to sql server 2000 thru weblogic

 
krish reddy
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi here is the code

im getting the same error no matter what.
ive set the class path, and included jar files in the weblogic/bin directory
ive tried all day and about to
Can somebody please help me with this i m new to jdbc

[added code tags]
[ January 28, 2006: Message edited by: Jeanne Boyarsky ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Krish,
What error are you getting? When you start up the server, is the datasource binding successfully?

This may be a weblogic question, but we can move it to the weblogic forum later after we see how the problem goes.
 
krish reddy
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes the datasource in binding, ive created and deployed datasource without any errors.
here is the error message i recieve when i compile the above program
------------------------------------------------------------------------
javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLIntialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLIntialContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at sq4.main(sq4.java:18)
Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLIntialContextFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 5 more
--------------------------------------------------------------------------

i think its a classpath problem
 
krish reddy
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i solved the problem by including sqldriver.jar,
but now its show this error
java.lang.UnsupportedClassVersionError: sq4 (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)

im using jdk 1.5
im not sure what to do
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that WebLogic Server < 9.0 does not support Java 1.5.
 
krish reddy
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Properties pros = new Properties();
pros.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
pros.put(Context.PROVIDER_URL,"t3://localhost:7001");

System.out.println("Connecting to webserver...");
Context conx = new InitialContext(pros);

System.out.println("looking up jndi name");
DataSource ds = (DataSource)conx.lookup("coolie");

System.out.println("jndi name found");
System.out.println("Connecting to sql server");

Connection conn = ds.getConnection();
System.out.println("Connection got..");
//Statement stmt = conn.createStatement();
//System.out.println("Creating table");
//stmt.execute("Create table Student(name varchar(20))");
//System.out.println("Table created");

System.out.println("Inserting into table");
PreparedStatement pstmt = conn.prepareStatement("insert into table Student(name values(?))");
pstmt.setString(1,"Thilak");
pstmt.addBatch();
pstmt.setString(2,"san");
pstmt.addBatch();



ok ive got the program to run.
But it gets stuch at ds.getConnection()and does nothing
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic