[SQLServer] The Object Name 'users' is invalid.

Source: Internet
Author: User

 

 

Package SSD; import Java. SQL. connection; import Java. SQL. drivermanager; import Java. SQL. resultset; import Java. SQL. statement; public class SDD {public static void main (string [] SRG) {string drivername = "com. microsoft. sqlserver. JDBC. sqlserverdriver "; // load the JDBC driver string dburl =" JDBC: Microsoft: sqlserver: // 127.0.0.1: 1433; databasename = lianxi "; // connect the server and database string username = "sa"; // password string Password = "sa" ; Connection dbconn = NULL; statement sta = NULL; resultset rs = NULL; try {class. forname (drivername); dbconn = drivermanager. getconnection (dburl, username, password); system. out. println ("database connection successful! "); STA = dbconn. createstatement (); RS = sta.exe cutequery ("select * from users"); While (RS. next () {system. out. println (RS. getstring (1); system. out. println (RS. getstring (2) ;}} catch (exception e) {system. err. println ("exception:" + E. getmessage ());}}}

Appears
Java. SQL. SQLException: [Microsoft] [SQLServer 2000 Driver for JDBC] [SQLServer] The Object Name 'users' is invalid.
At com. microsoft. jdbc. base. BaseExceptions. createException (Unknown Source)
At com. microsoft. jdbc. base. BaseExceptions. getException (Unknown Source)
At com. microsoft. jdbc. sqlserver. tds. TDSRequest. processErrorToken (Unknown Source)
At com. microsoft. jdbc. sqlserver. tds. TDSRequest. processReplyToken (Unknown Source)
At com. microsoft. jdbc. sqlserver. tds. TDSExecuteRequest. processReplyToken (Unknown Source)
At com. microsoft. jdbc. sqlserver. tds. TDSRequest. processReply (Unknown Source)
At com. microsoft. jdbc. sqlserver. SQLServerImplStatement. getNextResultType (Unknown Source)
At com. microsoft. jdbc. base. BaseStatement. commonTransitionToState (Unknown Source)
At com. microsoft. jdbc. base. BaseStatement. postImplExecute (Unknown Source)
At com. microsoft. jdbc. base. BaseStatement. commonExecute (Unknown Source)
At com.microsoft.jdbc.base.BaseStatement.exe cuteQueryInternal (Unknown Source)
At com.microsoft.jdbc.base.BaseStatement.exe cuteQuery (Unknown Source)
......
Code:
String dbURL = "jdbc: microsoft: sqlserver: // localhost: 1433; DatabaseName = XXX
Note that localhost: 1433; there is a space behind it, so that the Database cannot be found, and the data table in it will certainly not be found.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.