Data | database | Database Connection Activation Blog Since the recent comparison also did not write what original article, now while idle time to write several hair up. Some time ago in the study of Java and database connection, send a little experience up.
There are two main ways to connect a database with Java, one is to connect with the Jdbc-odbc bridge, the other is to connect with the corresponding driver provided by the manufacturer, first of all to talk about the first connection.
The JDBC-ODBC bridge is implemented using Jdbcodbc.class and a local library for accessing ODBC drivers. For Windows platforms, the local library is a dynamic Connection library DLL (JDBCODBC. DLL).
Because JDBC is designed to be very close to ODBC. Internally, the driver maps the JDBC method to an ODBC call, so that JDBC can interact with any available ODBC driver. The advantage of this bridge is that it gives JDBC the ability to access almost all databases at present. The prevailing mode is as shown in the figure:
First open the Control Panel management tool, open the data source (ODBC), and add the data source (i.e. the name of the database you are connecting to) to the User DSN, where the goodssupply database is assumed to be connected to SQL SERVER 2000. Name fill in the name of the database you want to connect to (goodssupply), and then gradually set, if you choose to use the Sql-server password authentication, you must enter the appropriate username and password to connect to the database. All the way to the next setup complete.
In Java to write programs to test, where my program is to allow users to enter any table name and the name of the column, the column of all data output. The source code is as follows:
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.