[SQLServer] The Object Name & #39; users & #39; is invalid.

Source: Internet
Author: User
Packagessd; importjava. SQL. connection; importjava. SQL. driverManager; importjava. SQL. resultSet; importjava. SQL. statement; publicclasssdd {publicstaticvoidmain (String [] srg) {StringdriverNamecom. microsoft. sqlserver. jdbc. SQLServerDri

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. SQLServerDri

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]ObjectName 'users'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.