my dog learned polymorphism*
The moose likes Other Java Products and Servers and the fly likes JSP SQL server database connectivity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "JSP SQL server database connectivity" Watch "JSP SQL server database connectivity" New topic
Author

JSP SQL server database connectivity

Aparna Iyer
Greenhorn

Joined: Aug 01, 2005
Posts: 6
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

Joined: Jan 10, 2002
Posts: 60804
    
  65

Moved to the Other Servers forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Hi

Verify your classpath. The problem is in the classpath.

bye for now
sat
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45

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


That is not a class name, hence the driver class is not getting loaded.


Ping & DNS - my free Android networking tools app
Aparna Iyer
Greenhorn

Joined: Aug 01, 2005
Posts: 6
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

Joined: Aug 01, 2005
Posts: 6
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

Joined: May 03, 2004
Posts: 334
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
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP SQL server database connectivity
 
Similar Threads
Trouble connecting to MS Access via ODBC
Help needed with error SQLException: ORA-00928: missing SELECT keyword
newbie problem
problems with java
Multiple forms in a single JSP page