Home >Database >Mysql Tutorial >MySQL操作类(本人自己写的)_MySQL

MySQL操作类(本人自己写的)_MySQL

WBOY
WBOYOriginal
2016-06-01 13:17:18897browse
 1 package com.test; 2 import java.sql.Connection; 3 import java.sql.DriverManager; 4 import java.sql.PreparedStatement; 5 import java.sql.ResultSet; 6 import java.util.Vector; 7 public class DBUtil { 8      9     //定义连接数据库需要的10     Connection ct=null;11     PreparedStatement pS=null;12     ResultSet rS=null;13     private static String url = "jdbc:mysql://"+DBSomeType.MYSQLURL+":3306/weixin?characterEncoding=UTF-8&autoReconnect=true";14     private static String driverName = "com.mysql.jdbc.Driver";15     16     /**17      *  数据库查询,本操作查询完需手动关闭连接18      * @param sql19      * @param params20      * @return 查询结果ResultSet21      */22     public ResultSet getSlect(String sql,Object ...params){23         Vector rowDate=new Vector();24         Vector columnDate =new Vector();25         try {26             ct = connectWithDB();27             pS=ct.prepareStatement(sql);28             for(int i = 0;i <p> </p>
    
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn