SQL Server Java query working in one table and not in another -


I have a Java code that connects to the SQL Server 2008 R2 database.

I have two questions, which work fine in both MS SQL Server Management Studio, but only one of them works while executing with Java code. If the difference is only the questions that they use different tables, and two tables do not lie in the same database I all DBA, but as far as I can see, permissions for both tables are identical .

What can be wrong in the tables, and how should I see the difference?

Well, I edited the question to add details I've used the same Java code, just another change active SQL line with comments.

My java code snippet:

  // string sql = "TOP TOP 10 * FROM [ipm_data]. [Dbo]. [Table1]"; // works correctly String SQL = "Select [IPM_data] from the top 10 *. [DBO]. [Table 2]"; // stmt = con.createStatement () does not work; Rs = stmt.executeQuery (SQL);  

And with a non-functional query in the command prompt:

  & gt; Java connect URL2 com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'ipm_data.dbo.table2'. Com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult at (SQLServerStatement.java1515) com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement (SQLServerException.java:216) (sql) LServerStatement.java:792) at com.microsoft.sqlserver.jdbc.SQLServerStatement $ StmtExecCmd.doExecute (SQLServerStatement.java:689) at com.microsoft.sqlserver.jdbc.TDSCommand.execute (IOBuffer.java tips696) at com. On Com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement (SQLS) on com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand (SQLServerStatement.java:180). Microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand (SQLServerConnection.java:1271) ErverStatement.java:155) on URL2.main connect com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery (SQLServerStatement.java:616) (connectURL2.java: 74)  

Where is ConnectURL2.java:74 in the line: rs = stmt.executeQuery (SQL);

And once again, both queries are just fine when entering the management studio.


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -