我正在尝试将JPA与SQL Server一起使用。Eclipse有很好的工具来映射数据库中的实体,反之亦然。为此,我需要将连接关联到 JPA 项目。
所以我在这个数据库上创建了一个数据库(命名为“rowcount”)和一个表。然后,当我转到 Eclipse,打开 JPA 透视图,登录数据库(数据源资源管理器/数据库连接)时,我看不到与此特定数据库关联的任何模式。
查看 Eclipse 的“错误日志”视图,每次单击 Eclipse 上的“架构”树视图项时都会出现以下错误:
eclipse.buildId=M20130204-1200
java.version=1.7.0_15
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=pt_BR
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
Error
Tue May 21 10:34:42 BRT 2013
com.microsoft.sqlserver.jdbc.SQLServerException
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'rowcount'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:792)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:689)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(SQLServerStatement.java:616)
at org.eclipse.datatools.connectivity.sqm.internal.core.connection.StatementAdapter.executeQuery(StatementAdapter.java:73)
at org.eclipse.datatools.enablement.msft.internal.sqlserver.loaders.SQL2005SchemaLoader.createResultSet(SQL2005SchemaLoader.java:53)
at org.eclipse.datatools.connectivity.sqm.loader.JDBCSchemaLoader.loadSchemas(JDBCSchemaLoader.java:111)
at org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCCatalog.loadSchemas(JDBCCatalog.java:101)
at org.eclipse.datatools.connectivity.sqm.core.rte.jdbc.JDBCCatalog.getSchemas(JDBCCatalog.java:64)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.vnode.ServerExplorerVNodeContentProviderNav.displaySchemaNodeChildren(ServerExplorerVNodeContentProviderNav.java:126)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.AbstractOnDemandContentProviderNav.getChildren(AbstractOnDemandContentProviderNav.java:169)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.AbstractOnDemandContentProviderNav.getChildren(AbstractOnDemandContentProviderNav.java:243)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.layout.AbstractLayoutProviderNav.getChildren(AbstractLayoutProviderNav.java:85)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.providers.content.impl.ServerExplorerContentProviderNav.load(ServerExplorerContentProviderNav.java:153)
at org.eclipse.datatools.connectivity.sqm.server.internal.ui.explorer.loading.LoadingJob.run(LoadingJob.java:43)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
我在 JPA 驱动程序属性中使用最新的 sqljdbc4.jar 和“ Microsoft SQL Server 2008 JDBC 驱动程序”。
此错误阻止我在 EAR 文件中部署应用程序。即使我设法在 Weblogic 上手动部署它,应用程序也会因为以下原因而失败:
openjpa-1.1.1-SNAPSHOT-r422266:957329 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "SELECT N FROM Note N". Error message: The name "Note" is not a recognized entity or identifier. Known entity names: []
奇怪的是,“主”数据库显示了它的一些对象和模式。在 SQL Server、JDBC 驱动程序或 Eclipse 中是否有解决方法?