Class.forName("org.gjt.mm.mysql.Driver");
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
  con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");
  //接管数据库连接实例
  boolean coding = true;
  EncodingConnection codingConnection = new EncodingConnection(con, coding, "ISO-8859-1", "GBK");
  //获得接管后的数据库连接实例,以后直接使用con已经是经过EncodingConnection重新包装过的实例
  con = codingConnection.getConnection();
  pstmt = con.prepareStatement("SELECT f3, f4 FROM tbl1 WHERE f1 = ? AND f2 = ?");
  pstmt.setString(1, f1);
  pstmt.setString(2, f2);
  rs = pstmt.executeQuery();
  String f3, f4;
  while(rs.next()) {
    f3 = rs.getString(1);
    f4 = rs.getString(2);
  }
}
finally {
  //close resouces
  ...
}
试试这样来取得连接,来实现增删改查