1

我試圖在使用sqljdbc4的SQL SERVER 2008的Intellij中設置數據源,並收到java.lang.NullPointerException的錯誤窗口。在IntelliJ中爲SQL SERVER 2008設置數據源時出現NullPointerException

網址,我想: jdbc:sqlserver://localhost\.:1433;databaseName=mobitrack jdbc:sqlserver://localhost:1433;databaseName=mobitrack 但相同的結果。

關於什麼可能導致異常的任何想法?

預先感謝您。

這裏是例外的截圖: http://i.imgur.com/idIwYqP.png

idea.log:

2013-03-22 17:13:12,770 [7171087] INFO - ution.rmi.RemoteProcessSupport - "c:\program files\jetbrains\intellij idea 11.0\jre\jre\bin\java" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 11.0\plugins\DatabaseSupport\lib\jdbc-console.jar;C:\Program Files\JetBrains\IntelliJ IDEA 11.0\lib\util.jar;C:\Program Files\JetBrains\IntelliJ IDEA 11.0\lib\annotations.jar;D:\sqljdbc4-4.0.2206.100.jar" com.intellij.persistence.database.console.RemoteJdbcServer com.microsoft.sqlserver.jdbc.SQLServerDriver 
2013-03-22 17:13:13,532 [7171849] INFO - ution.rmi.RemoteProcessSupport - Port/ID:30598/RemoteDriverImple39ef7c1 
2013-03-22 17:13:14,333 [7172650] ERROR - j.javaee.dataSource.DataSource - null 
java.lang.NullPointerException 
    at com.intellij.javaee.dataSource.DatabaseSchemaLoader.getSchemasToLoad(DatabaseSchemaLoader.java:77) 
    at com.intellij.javaee.dataSource.DataSource$1.perform(DataSource.java:324) 
    at com.intellij.javaee.dataSource.DataSource$1.perform(DataSource.java:317) 
    at com.intellij.javaee.dataSource.DataSource.performJdbcOperation(DataSource.java:257) 
    at com.intellij.javaee.dataSource.DataSource.refreshMetaData(DataSource.java:317) 
    at com.intellij.javaee.module.view.dataSource.DataSourceUiUtil$4.run(DataSourceUiUtil.java:138) 
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:457) 
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$5.run(ProgressManagerImpl.java:276) 
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178) 
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:206) 
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:169) 
    at com.intellij.openapi.application.impl.ApplicationImpl$8$1.run(ApplicationImpl.java:617) 
    at com.intellij.openapi.application.impl.ApplicationImpl$6.run(ApplicationImpl.java:410) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) 
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:662) 
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:135) 
2013-03-22 17:13:14,334 [7172651] ERROR - j.javaee.dataSource.DataSource - IntelliJ IDEA 11.0 Build #IU-111.69 
2013-03-22 17:13:14,334 [7172651] ERROR - j.javaee.dataSource.DataSource - JDK: 1.6.0_29 
2013-03-22 17:13:14,334 [7172651] ERROR - j.javaee.dataSource.DataSource - VM: Java HotSpot(TM) Client VM 
2013-03-22 17:13:14,334 [7172651] ERROR - j.javaee.dataSource.DataSource - Vendor: Sun Microsystems Inc. 
2013-03-22 17:13:14,335 [7172652] ERROR - j.javaee.dataSource.DataSource - OS: Windows 7 
2013-03-22 17:13:14,353 [7172670] INFO - ution.rmi.RemoteProcessSupport - Process finished with exit code 1 
+1

請[提供idea.log](http://intellij-support.jetbrains.com/entries/23352446)。 – CrazyCoder 2013-03-22 15:55:25

+0

嘗試IDEA [11.1.5](http://devnet.jetbrains.com/docs/DOC-1228)或IDEA [12.1](http://confluence.jetbrains.com/display/IDEADEV/IDEA+12.1+EAP )。你的版本是古老的。另請檢查是否有[最新的JDBC驅動程序](http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774)或嘗試[jTDS驅動程序](http:// jtds.sourceforge.net/)。 – CrazyCoder 2013-03-22 20:11:35

+0

我更新了IDEA,它的工作非常感謝。順便說一下,問題在於舊IDEA無法識別它們之間的關係。 – Miro 2013-03-26 17:47:37

回答

0

是的,網址是不正確的。試試這個:

jdbc:sqlserver://localhost:1433;databaseName=mobitrack 

首先要做的是:SQL Server偵聽器是否在1433端口上偵聽並偵聽?

打開命令shell並鍵入netstat -a。如果在端口1433上看不到LISTENING,則Java將無法連接。

NullPointerException並不意味着你沒有連接。我敢打賭,別的是錯的。

打印堆棧跟蹤。它告訴你有一個空引用的文件和行號。在調試器中瀏覽一下,看看是什麼和爲什麼。

我不知道你從哪裏得到JDBC驅動程序JAR,但是我用於SQL Server的名稱是sqljdbc.jar。嘗試更新驅動程序JAR並查看是否有幫助。

我可以用IntelliJ做到這一點,所以你也可以。

+0

我已經做了。同樣的例外。 – Miro 2013-03-22 14:50:54

+0

嘗試使用127.0.0.1而不是localhost。 – duffymo 2013-03-22 15:13:10

+0

還是一樣的例外:http://i.imgur.com/MhsjK2B.png – Miro 2013-03-22 15:16:16

相關問題