This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP SQL server database connectivity

 
Aparna Iyer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I have this JSP code which works fine in Tomcat. But when I try to run it in JRun, it gives me an error:
ClassNotFoundException: jdbc:microsoft:sqlserver/SQLServerDriver()

Can you please help me?

I created the JDBC data source in teh JRun server. But I am a little un clear as to what I need to do in the JRun environment.

If any one has any samples (source code with database login etc and also instructions to create any data source in JRun) that would be great.

Thanks in advance for your help.

<%

out.println("test page");

try {

//DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());

Class.forName("jdbc:microsoft:sqlserver.SQLServerDriver()");

Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://<ipaddress> ORT","user","pass");

Statement stmt = connection.createStatement();

ResultSet rset = stmt.executeQuery("select ts_id from ttmaster_user.ts_labels");

while (rset.next()) {

out.println ("TS ID: " + rset.getString(1)); // Print col 1

}

stmt.close();

}

catch(SQLException e) {

out.println("SQLException: " + e.getMessage() + "<BR>");

while((e = e.getNextException()) != null)

out.println(e.getMessage() + "<BR>");

}

catch(ClassNotFoundException e) {

out.println("ClassNotFoundException: " + e.getMessage() + "<BR>");

}

%>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64975
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Other Servers forum.
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Verify your classpath. The problem is in the classpath.

bye for now
sat
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Class.forName("jdbc:microsoft:sqlserver.SQLServerDriver()");


That is not a class name, hence the driver class is not getting loaded.
 
Aparna Iyer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Can you please explain that? What do you mean by that is not class name? Can you please give me a sample and tell me how to load the driver class?
 
Aparna Iyer
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Satish, JRun admi says that the CLASSPATH is set properly. what shoukd he set the CLASSPATH to? Can you please send me the directory that he should include (I guess he already has the path where the mbase.jar file is, is there anything else he should add in class path for database connection?) Is there anything I should set?

Thanks in advance for your help Satish.
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am sure, your jdbc driver for sql server is not in the classpath. check again whether it is in the classpath.
I am not aware of the directory structure. Bcos I am not Using JRUN and SQL Server.
i will try to find the solution for your problem. give me some time

bye for now
sat
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Class.forName("jdbc:microsoft:sqlserver.SQLServerDriver()");

What do you mean by that is not class name? Can you please give me a sample and tell me how to load the driver class?


I mean exactly that: Class.forName takes as parameter a class name, and "jdbc:microsoft:sqlserver.SQLServerDriver()" is not a class name (it contains colons and parentheses). "jdbc.microsoft.sqlserver.SQLServerDriver" might be a class name; check the documentation of the driver, which you can find here
[ August 03, 2005: Message edited by: Ulf Dittmer ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic