1

我正在尝试使用 sqljdbc4 在 Intellij 中为 SQL SERVER 2008 设置数据源,并且收到带有 java.lang.NullPointerException 的错误窗口。

我试过的网址: jdbc:sqlserver://localhost\.:1433;databaseName=mobitrack jdbc:sqlserver://localhost:1433;databaseName=mobitrack 但结果相同。

关于什么可能导致异常的任何想法?

先感谢您。

这是异常的屏幕截图:http: //i.imgur.com/idIwYqP.png

想法日志:

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
4

1 回答 1

0

是的,那个网址不正确。尝试这个:

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

首先要做的事情是:SQL Server 侦听器是否启动并侦听端口 1433?

打开命令外壳并键入netstat -a. 如果LISTENING在端口 1433 上看不到,Java 将无法连接。

NullPointerException并不意味着你没有连接。我敢打赌,还有其他问题。

打印堆栈跟踪。它告诉您有空引用的文件和行号。在调试器中单步执行,看看是什么以及为什么。

我不知道您从哪里得到那个 JDBC 驱动程序 JAR,但我用于 SQL Server 的那个名为 sqljdbc.jar。尝试更新驱动程序 JAR,看看是否有帮助。

我可以用 IntelliJ 做到这一点,所以你也可以。

于 2013-03-22T14:44:10.117 回答