SQL Server: the ODBC Object Name *** is invalid and the database cannot be found.

Source: Internet
Author: User
Tags sql server driver odbc sql server driver

Features, causes, and solutions of the problem

1. Problem features

① The specified table cannot be found, which is similar"[Microsoft] [odbc SQL Server Driver] [SQL Server] The Object Name 'goods 'is invalid.".

② When configuring ODBC,When "select default database" is reached, the user's own database cannot be found. (1)

2. Cause: first, ensure that your SQL statement has no errors. (You can go to SQL Server to determine)

The cause of this problem is: When you configure ODBC, enter "." in the "Select Server" text box ".". (2)


Figure 1 The database cannot be configured properly when "." is selected on the server

Figure 2

3. How can the server be correctly entered? (Figure 3 shows the Database List displayed after the server is correctly configured) Figure 3 after the server is correctly configured, the optional database list is shown in Figure 3. The liangshanheros database is created by myself. This indicates that the server is correctly configured. In fact, the server name should be configured as the server you want to access now. Take SQL Server 2005 as an example, 4, my server name is: www-4677ba992fd \ sqlexpress

Figure 4 correct server name

Appendix:Use JDBC-ODBC to add a piece of data to the specified table and check whether the data is inserted successfully.

/*** @ Title: Test. Java * @ package * @ Description: JDBC-objc getting started Program : Inserts a piece of data into the specified table and tests whether the data is successfully inserted. * @ Author jogging Android * @ date 03:30:48 * @ version V1.0 */import Java. SQL. connection; import Java. SQL. drivermanager; import Java. SQL. sqlexception; import Java. SQL. statement; public class test {public static void main (string [] ARGs) {connection Ct = NULL; statement Sm = NULL; try {// 1. load the driver class. forname ("Sun. JDBC. ODBC. jdbcodbcdriver "); // 2. get the connection [specify the data source to connect to] // window authentication only requires: Ct = drivermanager. getco Nnection ("JDBC: ODBC: mytest"); Ct = drivermanager. getconnection ("JDBC: ODBC: mytest", "sa", "sapass"); system. out. println ("database connection successful"); // 3. create statement or preparedstatement [difference] // statement usage: Mainly used to send SQL statements to the database Sm = CT. createstatement (); // 4. execute (any operations can be performed on the database) // select the data database sm.exe cute ("use master") to operate "); // ② perform operations on the database int I = sm.exe cuteupdate ("insert into goods values ('20170101', 'tomato ', '2. 0', 'Go', '')"); if (1 = I) {system. Out. println ("inserted successfully");} else {system. out. println ("insertion failed") ;}} catch (classnotfoundexception e) {e. printstacktrace ();} catch (sqlexception e) {e. printstacktrace ();} finally {// release resource try {If (null! = Sm) {SM. Close () ;}if (null! = CT) {CT. Close () ;}} catch (exception e) {e. printstacktrace ();}}}}

Related Article

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.