1

I have to query MSSQL. I tried every solution but did not work. I tried both com.microsoft.sqlserver.jdbc.SQLServerDriver
and com.microsoft.jdbc.sqlserver.SQLServerDriver.

Where the problematic part may be ?

Thanks.

That's my repo. enter image description here

And the database service

     String connectionString = "";
    String JDBC_SQLSERVER_STRING = "jdbc:sqlserver://";
   //for (HierarchicalConfiguration database : databases) {
               try
               {


                       try {
                           Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                        // Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                       }
                       catch (ClassNotFoundException ex) {
                         throw new Exception();
                    }

        connectionString = JDBC_SQLSERVER_STRING + "xx" + ":" + "yy" + ";databaseName=" + "zz";
        Connection conn = DriverManager.getConnection(connectionString, "aa", "bb");
        PreparedStatement ps = conn.prepareStatement("SELECT TOP 10 * FROM zz.cc");  

1 Answer 1

1

Please share your pom.xml file, Are you using sqljdbc maven dependency or external .jar file ?

Here is the latest version of sqlserver maven dependency, Microsoft recently announces the open sourcing of the Microsoft JDBC Driver for SQL Server! Now you can directly use this below dependency instead of adding external lib:

<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version> 
</dependency>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.