sql语句查询数据库案例package st;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.hanqi.util.JdbcConnectionUtil;
public class Test {
private static Connection con; //链接数据库
private static PreparedStatement pste;// 执⾏sql语句
private static ResultSet rs; //执⾏返回结果
public static void main(String[] args) {
init();
String sql = "select * from appuser";
try {
pste = con.prepareStatement(sql);// 执⾏sql语句
rs = uteQuery();//执⾏完的返回结果
()) {
System.out.Int("id"));
System.out.String("username"));
System.out.String("password"));
System.out.String("realname"));
System.out.Date("createtime"));
System.out.println("================================");
}
} catch (SQLException e) {
e.printStackTrace();
}
close();
}
public static void init() {
con = Connection();
}
public static void close() {
JdbcConnectionUtil.destroy(con,pste,rs);
sql查询语句实例大全}
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。