SQL server 2000 is a widely used database system in network programming today, while java is a popular network programming language, in network programming, database issues are also important. java itself provides support for various mainstream database systems by providing java. the SQL database provides a unified interface, so that you do not have to modify the program in a large scale in the java environment. You only need to change the corresponding driver to perform operations on various databases, so as to improve the software life cycle and reduce software development costs and maintenance costs, in this case, the integration of SQL server 2000 and java becomes more important, this article briefly introduces the integration of SQL server 2000 and jdk.
System Requirements:
Database: SQL server 2000 sp3
Driver: SQL server driver for jdbc
Java version: jdk1.2 or later
1: We first use the jdbc-odbc bridge to connect databases. This is relatively simple.
First, use SQL server Enterprise to manage it to create a database test, and create a simple table first_table
Create an odbc Data Source by default.
Write a simple test program that connects to the database and performs a simple SQL operation. The Code is as follows:
/*************************************** ********
/*
/* DbTest. java
/*
/*************************************** *****/
Import java. SQL .*;
Public class DbTest {
Connection con;
Statement sta;
ResultSet rs;
String driver;
String url;
String user;
String pwd;
Public DbTest ()
{
Driver = "sun. jdbc. odbc. JdbcOdbcDriver ";
Url = "jdbc: odbc: store_manager ";
User = "share ";