Java/MSSQL: java.sql.SQLException Invalid object name 'TableName'

末鹿安然 提交于 2019-12-23 15:29:30

问题


I'm trying to move a java application from an old server to a new server. The application runs on Tomcat, uses Microsoft SQL Server as the backend DB, and used a system DSN defined in Data Sources (ODBC) to decide where to connect to. The old server used Windows 2000/SQL server 2000, the new server uses Windows 2003/SQL Server 2005.

The ODBC definition is identical between servers, and defines the DB to use.

On the new server when a user tries to login the following appears in the stdout.log:

user is being checked Error: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'UserTable'.

A table called UserTable does exist in the DB, but shows as "dbo.USerTable" through the management interface.

Is there a setting somewhere in MSSQL I should be adjusting to make it happy with the "dbo." prefix being missing, or is there something else I've missed?

[edit] Windows authentication is used, and the Public and Guest roles have been given full rights to the DB as a troubleshooting step.


回答1:


Are the DB logins different? the dbo "prefix" is just the schema that the object is defined under. So if your ODBC connector is using the dbo credentials to login that object should be in it's default schema.




回答2:


Do you have to use ODBC in the first place? In my experience the "native" (type 4) SQL Server drivers are better. There's a Microsoft driver and jTDS. I don't have much experience with the MS driver, but the jTDS one is good.

Of course, if you're forced to use ODBC by other factors, this won't be any use to you - but if you have the option, it would be worth a try. It would be one fewer thing to configure on the Windows box.



来源:https://stackoverflow.com/questions/909599/java-mssql-java-sql-sqlexception-invalid-object-name-tablename

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!