标签:
程序如下:
--第一个类:
package com.StudentCurriculavariable;
import java.sql.*;
public class JDBC_Connection {
static String drivername="sun.jdbc.odbc.JdbcOdbcDriver";
static String url="jdbc:odbc:chong";
static String username="sa";
static String password="123456";
static{
try{
Class.forName(drivername);
System.out.println("创建成功!");
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
public static Connection getConnection(){
Connection conn=null;
try{
conn=DriverManager.getConnection(url,username,password);
System.out.println("连接数据库成功!");
}catch(SQLException e){
e.printStackT