package com.gx.bean;
import java.sql.*;public class conn {
public Connection getconn() throws SQLException{
Connection conn=null;
try{
Class.forName("com.mysql.jdbc.odbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/stu","root","123456");
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
e.printStackTrace();
}
return conn;
}
public PreparedStatement prepare(Connection conn , String sql){
PreparedStatement pstmt=null;
try{
if(conn!=null){
pstmt=conn.prepareStatement(sql);
}
}catch(SQLException e){
e.printStackTrace();
}
return pstmt;
}
public Statement getStatement (Connection conn){
Statement stmt=null;
try{
if(conn != null)
{
stmt=conn.createStatement();
}
}catch(SQLException e)
{
e.printStackTrace();
}
return stmt;
}
public ResultSet getResultSet(Statement stmt, String sql){
ResultSet rs=null;
try{
if(stmt!=null){
rs=stmt.executeQuery(sql);
}
}
catch(SQLException e){
e.printStackTrace();
}
return rs;
public void executeUpdate(Statement stmt, String sql){//问题出在这里请大家看看 问题在哪里?
try{
if(stmt!=null){
stmt.executeQuery(sql);
}
}catch(SQLException e){
e.printStackTrace();
}
}
}
public void close(Connection conn){
try{
if(conn!=null){
conn.close();
conn=null;
}
}catch(SQLException e){
e.printStackTrace();
}
}
public void close(Statement stmt){
try{
if(stmt!=null){
stmt.close();
stmt=null;
}
}catch(SQLException e){
e.printStackTrace();
}
}
public void close (ResultSet rs){
try{
if(rs!=null){
rs.close();
rs=null;
}
}
catch(SQLException e){
e.printStackTrace();
}
}
}
import java.sql.*;public class conn {
public Connection getconn() throws SQLException{
Connection conn=null;
try{
Class.forName("com.mysql.jdbc.odbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/stu","root","123456");
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
e.printStackTrace();
}
return conn;
}
public PreparedStatement prepare(Connection conn , String sql){
PreparedStatement pstmt=null;
try{
if(conn!=null){
pstmt=conn.prepareStatement(sql);
}
}catch(SQLException e){
e.printStackTrace();
}
return pstmt;
}
public Statement getStatement (Connection conn){
Statement stmt=null;
try{
if(conn != null)
{
stmt=conn.createStatement();
}
}catch(SQLException e)
{
e.printStackTrace();
}
return stmt;
}
public ResultSet getResultSet(Statement stmt, String sql){
ResultSet rs=null;
try{
if(stmt!=null){
rs=stmt.executeQuery(sql);
}
}
catch(SQLException e){
e.printStackTrace();
}
return rs;
public void executeUpdate(Statement stmt, String sql){//问题出在这里请大家看看 问题在哪里?
try{
if(stmt!=null){
stmt.executeQuery(sql);
}
}catch(SQLException e){
e.printStackTrace();
}
}
}
public void close(Connection conn){
try{
if(conn!=null){
conn.close();
conn=null;
}
}catch(SQLException e){
e.printStackTrace();
}
}
public void close(Statement stmt){
try{
if(stmt!=null){
stmt.close();
stmt=null;
}
}catch(SQLException e){
e.printStackTrace();
}
}
public void close (ResultSet rs){
try{
if(rs!=null){
rs.close();
rs=null;
}
}
catch(SQLException e){
e.printStackTrace();
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货