如何建立一个JDBC程序?
import
java.sql.Connection;
import
java.sql.DriverManager;
import
java.sql.ResultSet;
import
java.sql.SQLException;
import
java.sql.Statement;
import
java.util.ArrayList;
import
java.util.List;
// 用户类,存储单个用户信息
class
User {
private
int
id;
private
String name;
public
User(
int
id, String name) {
this
.id = id;
this
.name = name;
}
public
int
getId() {
return
id;
}
public
void
setId(
int
id) {
this
.id = id;
}
public
String getName() {
return
name;
}
public
void
setName(String name) {
this
.name = name;
}
@Override
public
String toString() {
return
"User [id="
+ id +
", name="
+ name +
"]"
;
}
}