不会吧?这么夸张?!我写得不好,如果你不介意,可以参考下我的吧,不过是业余水平的拉。
import java.util.*;
import java.sql.*;
import java.io.*;
import java.sql.*;public class mysql {
  Connection conn=null;
  Statement statement=null;
  PreparedStatement pstmt=null;
  ResultSet rs=null;  public mysql(){
    try{ 
Class.forName("org.gjt.mm.mysql.Driver");
       }catch(ClassNotFoundException e)
   {System.err.println("mysql():"+e.getMessage());}

String url="jdbc:mysql://localhost:3306/Sample?user=root;password=";
    try{
conn=DriverManager.getConnection(url);
statement = conn.createStatement();
       }catch(SQLException sqlEx)
   {System.err.println(sqlEx.getMessage());} 
     }
   
   public ResultSet executeQuery(String sql)
     {   
try{
    rs = statement.executeQuery(sql);
   }catch(SQLException ex)
{
   System.err.println("executeQuery():"+ex.getMessage());
}
return rs;
      }   public int executeUpdate(String sql)
     {   
int i=0;
try{
    i = statement.executeUpdate(sql);
   }catch(SQLException ex)
{
   System.err.println("executeUpdate():"+ex.getMessage());
}
return i;
     }
}