java中的jdbc 怎么实现mysql 增删改查? jdbc连接mysql有是缺点? mysql确定不收费吗?
发布网友
发布时间:2022-04-07 16:01
我来回答
共2个回答
热心网友
时间:2022-04-07 17:30
标准SQL都是一样的,在网上下载一些连接MYSQL数据库的源码就行了
热心网友
时间:2022-04-07 18:48
/**
* 查找数据库总共有多少条记录
*/
public int findAllEmailCount() {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "select count(*) from email";
int count = 0;
try {
conn = DBHelp.getConnection();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next()){
count = rs.getInt(1);
}
} catch (Exception e) {
throw new RuntimeException("查找数据库出错");
} finally {
DBHelp.closeAll(null, pstmt, conn);
}
return count;
}