2012-03-08 22 views
0

私は自分のPCとMac(netbeans)で同じプロジェクトを持っています。私がMacでそれを開こうとすると「適切なドライバが見つかりません」と表示されます。私は両方で同じライブラリ/プロジェクトを使用しています。私はglassfishフォルダの中にコネクタのライブラリファイルを手動で追加する必要があることを読んでいましたか?java.sql.SQLException:netbeansに適切なドライバが見つかりません

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 8, 2012 5:30:43 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:159) 
    at Core.Configuration.Configure(Configuration.java:62) 
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51) 
Mar 8, 2012 5:30:43 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:266) 
    at Core.Configuration.Configure(Configuration.java:63) 
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51) 
Mar 8, 2012 5:30:43 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:178) 
    at Core.Configuration.ReadCurrentConfiguration(Configuration.java:237) 
    at Core.Configuration.Configure(Configuration.java:64) 
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51) 
Mar 8, 2012 5:30:43 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:311) 
    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 8, 2012 5:30:43 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:105) 
    at Core.Configuration.InsertConfig(Configuration.java:225) 
    at Core.Configuration.Configure(Configuration.java:68) 
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51) 
Mar 8, 2012 5:30:43 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:178) 
    at Core.Configuration.ReadCurrentConfiguration(Configuration.java:237) 
    at Core.Configuration.Configure(Configuration.java:69) 
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51) 
Mar 8, 2012 5:30:43 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:408) 
    at Core.Configuration.ReadEssentialAppliances(Configuration.java:115) 
    at Core.Configuration.Configure(Configuration.java:71) 
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51) 
Mar 8, 2012 5:30:43 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:356) 
    at Core.Configuration.ReadNonEssentialAppliances(Configuration.java:144) 
    at Core.Configuration.Configure(Configuration.java:72) 
    at desktopapplication2.DesktopApplication2.main(DesktopApplication2.java:51) 
Mar 8, 2012 5:30:43 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 8, 2012 5:30:43 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:222) 
    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) 
Mar 8, 2012 5:30:45 PM Database.Database databaseDataReturn 
WARNING: 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.databaseDataReturn(Database.java:459) 
    at desktopapplication2.DesktopApplication2View.<init>(DesktopApplication2View.java:68) 
    at desktopapplication2.DesktopApplication2.startup(DesktopApplication2.java:25) 
    at org.jdesktop.application.Application$1.run(Application.java:171) 
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) 
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677) 
    at java.awt.EventQueue.access$000(EventQueue.java:85) 
    at java.awt.EventQueue$1.run(EventQueue.java:638) 
    at java.awt.EventQueue$1.run(EventQueue.java:636) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) 
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:647) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188) 
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) 
Mar 8, 2012 5:30:45 PM Database.Database databaseDataReturn 
WARNING: 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.databaseDataReturn(Database.java:459) 
    at desktopapplication2.DesktopApplication2View.<init>(DesktopApplication2View.java:75) 
    at desktopapplication2.DesktopApplication2.startup(DesktopApplication2.java:25) 
    at org.jdesktop.application.Application$1.run(Application.java:171) 
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) 
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677) 
    at java.awt.EventQueue.access$000(EventQueue.java:85) 
    at java.awt.EventQueue$1.run(EventQueue.java:638) 
    at java.awt.EventQueue$1.run(EventQueue.java:636) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) 
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:647) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188) 
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) 
BUILD SUCCESSFUL (total time: 4 seconds) 
+0

あなたのプロジェクトのlibにはjarが必要ですか? – kosa

+0

はい私はそれを追加します。しかし、私はそれが実行され、私は別のフォルダにそれをインポートするよりも配置する必要が検出されない場合がありますいくつかの部分を読んだ。私はどこにいますか? –

+0

サーバのextフォルダ – kosa

答えて

0

後は、SQLServerデータベースから読み取るための単純なコードは次のとおりです。しかし、私はどこ

私は次のエラーを取得する知りません。 データベース名は "database1"です。 テーブル名は「table1」です。 "uname"と "pass"の2つの列があります。 "sqljdbc4.jar"をプロジェクトに追加することを忘れないでください。

public class NewClass { 

    public static void main(String[] args) { 

     Connection conn = null; 
     String dbName = "database1"; 
     String serverip="192.168.100.100"; 
     String serverport="1433"; 
     String url = "jdbc:sqlserver://"+serverip+"\\SQLEXPRESS:"+serverport+";databaseName="+dbName+""; 
     Statement stmt = null; 
     ResultSet result = null; 
     String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; 
     String databaseUserName = "admin"; 
     String databasePassword = "root"; 
     try { 
      Class.forName(driver).newInstance(); 
      conn = DriverManager.getConnection(url, databaseUserName, databasePassword); 
      stmt = conn.createStatement(); 
      result = null; 
      String pa,us; 
      result = stmt.executeQuery("select * from table1 "); 

      while (result.next()) { 
       us=result.getString("uname"); 
       pa = result.getString("pass");    
       System.out.println(us+" "+pa); 
      } 

      conn.close(); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 
} 
関連する問題