Note that there are some explanatory texts on larger screens.

plurals
  1. POJDBC connection works in IDE (eclipse), but not in .jar file
    primarykey
    data
    text
    <p>I'm really looking at a mystery here. I created a Java program in Eclipse and established a JDBC connection. The code is the following:</p> <pre><code>import java.sql.*; public class Login { public static void main(String[] args) { try { // Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection connection = DriverManager .getConnection("jdbc:sqlserver://localhost;databaseName=testdb; integratedSecurity=true;"); //adding port 1433 doesn't make a difference System.out.println("Connection successful"); Statement st = connection.createStatement(); ResultSet rs = st.executeQuery("select * from testtable"); while (rs.next()) { line = rs.getString(2); } } catch (Exception e) { e.printStackTrace(); } } } </code></pre> <p>When I'm running it within eclipse, everything's fine. The database and tables are good, library and authentication in the <strong>Java Built Path</strong> are set and I get the result I want, namely "Hello World", which is a string in the selected table.</p> <p>But creating an executable JAR file and running it throws the exception "<strong>This driver is not configured for integrated authentication</strong>". It does not even connect, so even if there was an error in the database it wouldn't matter at this point.</p> <p>Even more confusing is the fact, that some weeks earlier, I also created an executable JAR file and it worked!</p> <p><strong>OS</strong>: Windows Vista Home Premium x86</p> <p><strong>JDBC driver location</strong>: "C:\sqljdbc_4.0\enu\sqljdbc4.jar"</p> <p><strong>Native library location</strong>: "C:\sqljdbc_4.0\enu\auth\x86"</p> <p><strong>Java version</strong>: Java 7 Update 17 and JDK 7 Update 17</p> <p>Previousely, I used Update 21, but I changed back to check if the driver could be the reason.</p> <p>So, any suggestions? I'd be very grateful!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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