I know this is a basic question, but I can't seem to find an answer and I apologize, if this question is way too stupid, but here we go:
I am supposed to work with SQL Server (no problem so far) and with Java (love java, so no problem here either), but now: What am I supposed to do to make the combination work? I got: JRE 1.6 and the sqljdbc4.jar ... Before I put sqljdbc4.jar into my classpath I had sqljdbc.jar in it and with a test-program I got this exception:
21.08.2009 09:26:59 com.microsoft.sqlserver.jdbc.SQLServerConnection <init>
SCHWERWIEGEND: Die Java-Laufzeitumgebung (Java Runtime Environment, JRE), Version 1.6,
wird von diesem Treiber nicht unterstützt. Verwenden Sie die Klassenbibliothek
'sqljdbc4.jar', die Unterstützung für JDBC 4.0 bietet.
java.lang.UnsupportedOperationException: Die Java-Laufzeitumgebung (Java Runtime
Environment, JRE), Version 1.6, wird von diesem Treiber nicht unterstützt. Verwenden
Sie die Klassenbibliothek 'sqljdbc4.jar', die Unterstützung für JDBC 4.0 bietet.
at com.microsoft.sqlserver.jdbc.SQLServerConnection.<init>(SQLServerConnection.java:223)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:840)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at msSqlTest.DB.dbConnect(DB.java:13)
at msSqlTest.TestConnection.main(TestConnection.java:7)
Sorry for the German ... It basically means, that I should use sqljdbc4.jar, b/c the JRE I am using is not supported by the driver. So I put sqljdbc4.jar into my classpath, but it didn't work, so I am kinda lost, what I could do.
Maybe someone could tell be in an idiot-proof way what I should do :(
Oh yeah, here is the test-prog I use:
import java.sql.*;
public class TestConnection{
public static void main(String[] args){
// Neue DB und los geht's :)
DB db = new DB();
db.dbConnect(
"jdbc:sqlserver://localhost:1433/muff",
"user",
"pw" );
}
}
class DB{
public DB() {}
public void dbConnect( String db_connect_string,
String db_userid,
String db_password){
try{
Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" );
Connection conn = DriverManager.getConnection(
db_connect_string,
db_userid,
db_password);
System.out.println( "connected" );
}
catch( Exception e ){
e.printStackTrace();
}
}
};