RobertStout Posted February 15, 2005 Posted February 15, 2005 Hi, I need to connect a J# app to SQL Server 2000 using JDBC. Sadly, I can't use ADO.NET as one of the restrictions is no ms extensions. I have the SQL Server 2000 Driver for JDBC installed. I assume I will need it? Can anyone point me in the right direction? Thank you. ;) Quote
RobertStout Posted February 16, 2005 Author Posted February 16, 2005 Here is the source code for what I have come up with.. try { // Register the driver Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); // Pass connection URL Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver:[i]//SERVERNAME[/i]:[i]1433[/i]", "[i]USERNAME[/i]", "[i]PASSWORD[/i]"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM CLDatabases"); // Test data retrieval (first two table columns) while (rs.next()) ; { String colOne = rs.getString("DATABASEKEY"); String colTwo = rs.getString("SERVERTYPE"); System.out.println( colOne + " " + colTwo ); } } catch (Exception ex) { ex.printStackTrace(); } In the actual code, the italic text is set to (I believe) the relevant arguments. This statement: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Causes the following exception: [java.lang.ClassNotFoundException]{"com.microsoft.jdbc.sqlserver.SQLServerDriver"}java.lang.ClassNotFoundException Any ideas on why this exception is being thrown by this statement? Thanks, Rob Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.