Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make Java work with SQL Server?
    text
    copied!<p>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:</p> <p>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: <strong>JRE 1.6</strong> and the <strong>sqljdbc4.jar</strong> ... Before I put sqljdbc4.jar into my classpath I had sqljdbc.jar in it and with a test-program I got this exception:</p> <pre><code>21.08.2009 09:26:59 com.microsoft.sqlserver.jdbc.SQLServerConnection &lt;init&gt; 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.&lt;init&gt;(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) </code></pre> <p>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.</p> <p>Maybe someone could tell be in an idiot-proof way what I should do :(</p> <p>Oh yeah, here is the test appI use:</p> <pre><code>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 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(); } } }; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload