Netbeans找不到合适的数据库

时间:2012-03-06 16:25:00

标签: java netbeans

似乎我无法连接到数据库,我不确定为什么。数据库连接属性(id,密码,url)是正确的我检查但是我不知道如何解决问题。我收到以下错误。

    Mar 6, 2012 4:22:56 PM Database.Database Configure
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.Configure(Database.java:50)
    at Core.Configuration.Configure(Configuration.java:61)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51)
Mar 6, 2012 4:22:56 PM Database.Database InsertSimulation
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.InsertSimulation(Database.java:219)
    at Core.Configuration.Configure(Configuration.java:62)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51)
Mar 6, 2012 4:22:56 PM Database.Database ReadCurrentSimulation
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.ReadCurrentSimulation(Database.java:341)
    at Core.Configuration.Configure(Configuration.java:63)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51)
Mar 6, 2012 4:22:56 PM Database.Database ReadCurrentConfiguration
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.ReadCurrentConfiguration(Database.java:253)
    at Core.Configuration.ReadCurrentConfiguration(Configuration.java:237)
    at Core.Configuration.Configure(Configuration.java:64)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51)
Mar 6, 2012 4:22:56 PM Database.Database ReadCurrentConfigAsString
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.ReadCurrentConfigAsString(Database.java:386)
    at Core.Configuration.ReadConfigFromDB(Configuration.java:172)
    at Core.Configuration.CompareConfig(Configuration.java:203)
    at Core.Configuration.Configure(Configuration.java:66)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51)
Mar 6, 2012 4:22:56 PM Database.Database InsertConfiguration
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.InsertConfiguration(Database.java:120)
    at Core.Configuration.InsertConfig(Configuration.java:225)
    at Core.Configuration.Configure(Configuration.java:68)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51)
Mar 6, 2012 4:22:56 PM Database.Database ReadCurrentConfiguration
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.ReadCurrentConfiguration(Database.java:253)
    at Core.Configuration.ReadCurrentConfiguration(Configuration.java:237)
    at Core.Configuration.Configure(Configuration.java:69)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51)
Mar 6, 2012 4:22:56 PM Database.Database ReadEssentialAppliances
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.ReadEssentialAppliances(Database.java:483)
    at Core.Configuration.ReadEssentialAppliances(Configuration.java:115)
    at Core.Configuration.Configure(Configuration.java:71)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51)
Mar 6, 2012 4:22:56 PM Database.Database ReadNonEssentialAppliances
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.ReadNonEssentialAppliances(Database.java:431)
    at Core.Configuration.ReadNonEssentialAppliances(Configuration.java:144)
    at Core.Configuration.Configure(Configuration.java:72)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51)
Mar 6, 2012 4:22:56 PM Database.Database InsertHome
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.InsertHome(Database.java:90)
    at Core.SmartHome.InsertSmartHome(SmartHome.java:34)
    at Core.SmartHome.<init>(SmartHome.java:28)
    at Core.Processor.CreateHomes(Processor.java:65)
    at Core.Processor.Start(Processor.java:43)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:52)
Mar 6, 2012 4:22:56 PM Database.Database ReadCurrentHome
SEVERE: No suitable driver found for 
java.sql.SQLException: No suitable driver found for 
    at java.sql.DriverManager.getConnection(DriverManager.java:602)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at Database.Database.ReadCurrentHome(Database.java:297)
    at Core.SmartHome.InsertSmartHome(SmartHome.java:35)
    at Core.SmartHome.<init>(SmartHome.java:28)
    at Core.Processor.CreateHomes(Processor.java:65)
    at Core.Processor.Start(Processor.java:43)
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:52)

2 个答案:

答案 0 :(得分:0)

尝试通过在获取数据库连接的语句之前调用Class.forName()来手动加载驱动程序类。例如,如果您使用的是MySQL数据库,请在语句上方添加以下语句以获取数据库连接。

Class.forName("com.mysql.jdbc.Driver");

答案 1 :(得分:0)

尝试使用以下步骤将数据库驱动程序(JAR(s))添加到类路径中。这应该可以解决您的问题。

1. Select your project from the Projects explorer.
2. Right click -> Properties.
3. Select Libraries from Categories list.
4. Click on Add JAR/Folder button.
5. Add your jar(s) & click on OK to finish the process.