简体   繁体   中英

I am a newbie with java and I am trying to connect to a derby database. I am using netbeans 7.4

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnect {


public static void main(String[] args) {

    String host = ("jdbc:derby://localhost:1527/Employees");
    String uName = ("sa");
    String uPass = ("saa");
try {

    Connection con = DriverManager.getConnection(host, uName, uPass);
}
catch ( SQLException err) {
    System.out.println( err.getMessage());
}
}

}

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - exception java.sql.SQLException is never th [missing fragment here]

The code looks fine except that you misspelled DriverManager as DriveManager . (Notice the missing 'r')

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