简体   繁体   中英

java.sql.SQLException: No suitable driver found for jdbc:sqlserver tried classpath already

The sqljdbc4.jar isn't loaded or recognized even after following the steps from: java.sql.SQLException: No suitable driver found for jdbc:derby:

With this command the application does not start outside netbeans. Starting it only with: java -jar FXProductWatcher.jar # does not load the driver .jar

PS C:\\Documents and Settings\\User1\\Meus documentos\\x\\workspace\\FXProductWatcher\\dist> java -classpath 'C:\\Documents and Settings\\User1\\Meus documentos\\x\\workspace\\FXProductWatcher\\dist\\lib\\sqljdbc4.jar;FXProductWatcher.jar' FXProductWatcher

Results in> Error not able to locate or load main class FXProductWatcher

I'm using netbeans the manifest file is being generated automatically. I tried placing Class-Path: lib/sqljdbc4.jar but with no positive result.

The manifest from netbeans has:

JavaFX-Application-Class: fxproductwatcher.FXProductWatcher
JavaFX-Class-Path: lib/sqljdbc4.jar
Created-By: JavaFX Packager
Main-Class: com/javafx/main/Main

My connection code

try {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(DbConnection.class.getName()).log(Level.SEVERE, null, ex);
    }

    String sDbUrl = "jdbc:sqlserver://remoteIP;databaseName=test";

    conn = DriverManager.getConnection(sDbUrl, username, password);
    return conn;

Thanks for any help or sugestion.

Brother the url which you are using is :: jdbc:sqlserver://remoteIP;databaseName=test the ":"after sqlserver is not valid.

try this: jdbc:sqlserver//remoteIP;databaseName=test

this may work. good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM