Java数据库编程中sql server 2000的连接
来源:百度知道 编辑:UC知道 时间:2024/09/12 17:26:10
import java.sql.*;
public class DBMain
{public static void main(String args[])
{String dbdriver="sun.jdbc.odbc.JdbcOdbcDriver";
String dburl="jdbc:odbc:student_SQLServer";
String dbuser="sa";
String dbpassword="wangxuegao";
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
try{
Class.forName(dbdriver);
con=DriverManager.getConnection(dburl,dbuser,dbpassword);
stmt=con.createStatement();
rs=stmt.executeQuery("select * from qiang");
while(rs.next())
{System.out.println("ID:"+rs.getString("id"));
System.out.println("姓名"+rs.getString("name"));
System.out.println("密码"+rs.getString("password"));
System.out.println("年龄"+rs.getInt("age"));
System.out.println("E-mail"
public class DBMain
{public static void main(String args[])
{String dbdriver="sun.jdbc.odbc.JdbcOdbcDriver";
String dburl="jdbc:odbc:student_SQLServer";
String dbuser="sa";
String dbpassword="wangxuegao";
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
try{
Class.forName(dbdriver);
con=DriverManager.getConnection(dburl,dbuser,dbpassword);
stmt=con.createStatement();
rs=stmt.executeQuery("select * from qiang");
while(rs.next())
{System.out.println("ID:"+rs.getString("id"));
System.out.println("姓名"+rs.getString("name"));
System.out.println("密码"+rs.getString("password"));
System.out.println("年龄"+rs.getInt("age"));
System.out.println("E-mail"
要指出选择的是那一条记录
select * from qiang where id=?
Column not found 字段不能找到,你确定你ResultSet在get的时候那些什么id,name之类的没错?