surprise!

Hi all,

we got a new server, need to move all data from old to new, I have tomcat 5.5.9, jdk 1.5; Ms sql server package4 on Windows 2003.

I didn't download the driver yet. and not set the class for the driver, how come I can use my java servelet programmer to access, search the datbase by localhost. do I realy need JDBC driver?

Thank you

[366 byte] By [TMarya] at [2007-10-2 17:51:06]
# 1

> I didn't download the driver yet. and not set the

> class for the driver, how come I can use my java

> servelet programmer to access, search the datbase by

> localhost. do I realy need JDBC driver?

Your JDBC driver is probably packaged in your web application in the WEB-INF/lib.

I wouldn't be surprised unless you provide more information.

aniseeda at 2007-7-13 19:09:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

:(

> we got a new server, need to move all data from old

> to new, I have tomcat 5.5.9, jdk 1.5; Ms sql server

> package4 on Windows 2003.

> I didn't download the driver yet.

Yes you did.

> and not set the

> class for the driver,

Yes you did.

>how come I can use my java

> servelet programmer to access,

> search the datbase by

> localhost.

Because you did do (or someone did or something did) the things above you said you didn't do. If you didn't do those things it wouldn't work.

>do I realy need JDBC driver?

Yes. 100% Yes. No if. No maybe. No unless.

Yes you have to have a JDBC driver.

Luckily you already have one so it all worked out fine.

> Thank you

Your post gave me heartburn.

aniseeda at 2007-7-13 19:09:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
Faith-based computing at its finest.%
duffymoa at 2007-7-13 19:09:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

Hi , yest I did have three jar files in WEB-INF lib , not other touch this project, but I did nont set the class path, C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\ mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\ msutil.jar

, do I need to put this part on my classpath?

TMarya at 2007-7-13 19:09:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

Hi all,

now I have the following classpath

.;D:\Servlets+JSP;D:\jakarta-tomcat-5.5.9\common\lib\servlet-api.jar;D:\jakarta-tomcat-5.5.9\common\lib\jsp-api.jar;D:\ jdk1.5.0_06\lib\tools.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar [ /code]

my programmer under tomcat work fine , but my client code not work I got java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

at java.net.URLClassLoader$1.run(Unknown Source) why[code]import java.sql.*;

public class connect{

private java.sql.Connection con = null;

private final String url = "jdbc:microsoft:sqlserver://";

private final String serverName= "localhost";

private final String portNumber = "1433";

private final String databaseName= "pubs";

private final String userName = "test";

private final String password = "1234";

// Informs the driver to use server a side-cursor,

// which permits more than one active statement

// on a connection.

private final String selectMethod = "cursor";

// Constructor

public connect(){}

private String getConnectionUrl(){

return url+serverName+":"+portNumber+";databaseName="+databaseName+";selectMethod="+selectMethod+";";

}

private java.sql.Connection getConnection(){

try{

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

con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password);

if(con!=null) System.out.println("Connection Successful!");

}catch(Exception e){

e.printStackTrace();

System.out.println("Error Trace in getConnection() : " + e.getMessage());

}

return con;

}

/*

Display the driver properties, database details

*/

public void displayDbProperties(){

java.sql.DatabaseMetaData dm = null;

java.sql.ResultSet rs = null;

try{

con= this.getConnection();

if(con!=null){

dm = con.getMetaData();

System.out.println("Driver Information");

System.out.println("\tDriver Name: "+ dm.getDriverName());

System.out.println("\tDriver Version: "+ dm.getDriverVersion ());

System.out.println("\nDatabase Information ");

System.out.println("\tDatabase Name: "+ dm.getDatabaseProductName());

System.out.println("\tDatabase Version: "+ dm.getDatabaseProductVersion());

System.out.println("Avalilable Catalogs ");

rs = dm.getCatalogs();

while(rs.next()){

System.out.println("\tcatalog: "+ rs.getString(1));

}

rs.close();

rs = null;

closeConnection();

}else System.out.println("Error: No active Connection");

}catch(Exception e){

e.printStackTrace();

}

dm=null;

}

private void closeConnection(){

try{

if(con!=null)

con.close();

con=null;

}catch(Exception e){

e.printStackTrace();

}

}

public static void main(String[] args) throws Exception

{

connect myDbTest = new connect();

myDbTest.displayDbProperties();

}

}

TMarya at 2007-7-13 19:09:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6
MS sql server package 4 work well with its package 2 driver, not that well with its package 3 driver.using package 2 driver work find bot server and client sides.thankyou
TMarya at 2007-7-13 19:09:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7
> MS sql server package 4 work well with its package 2> driver, not that well with its package 3 driver.> using package 2 driver work find bot server and> client sides.I don't understand your problem at all.
aniseeda at 2007-7-13 19:09:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8

> MS sql server package 4 work well with its package 2

> driver, not that well with its package 3 driver.

> using package 2 driver work find bot server and

> client sides.

Please translate the above mess into something that uses actual commonly used terminology. What does package mean? Driver type? Ms-SQL service pack? Something else?

What driver are you using? What problems are you having?

aniseeda at 2007-7-13 19:09:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...