File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes unable to connect to sql server 2000 thru weblogic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "unable to connect to sql server 2000 thru weblogic" Watch "unable to connect to sql server 2000 thru weblogic" New topic

unable to connect to sql server 2000 thru weblogic

krish reddy

Joined: Sep 09, 2005
Posts: 10
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

Joined: May 26, 2003
Posts: 33124

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
krish reddy

Joined: Sep 09, 2005
Posts: 10
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(
Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLIntialContextFactory
at$ Source)
at Method)
at 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

Joined: Sep 09, 2005
Posts: 10
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

Joined: Sep 29, 2002
Posts: 1683
Note that WebLogic Server < 9.0 does not support Java 1.5.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
krish reddy

Joined: Sep 09, 2005
Posts: 10
Properties pros = new Properties();

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(?))");

ok ive got the program to run.
But it gets stuch at ds.getConnection()and does nothing
I agree. Here's the link:
subject: unable to connect to sql server 2000 thru weblogic
It's not a secret anymore!