⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbtools.java

📁 仿校内网站
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//* * DBTools.java * * Created on 2008年1月10日, 上午8:07 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package ArticleSharing;import java.io.UnsupportedEncodingException;import java.sql.*;public class DBTools {    private Connection con = null;  // 数据库连接    private Statement stmt = null;  // 数据库命令        /** Creates a new instance of DBTools */    public DBTools() {	// 这里设置成private貌似就没有办法使用javaBean技术了……        try {            Class.forName("com.mysql.jdbc.Driver");            con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/dating_platform", "root", "1234");            stmt = con.createStatement();        }        catch(Exception e) {            e.printStackTrace();        }    }        public ResultSet excuteQuery(String sql) {        try {            ResultSet rs = stmt.executeQuery(sql);            return rs;        }        catch(Exception e) {            return null;        }    }        public int excuteUpdate(String sql) {        try {            return stmt.executeUpdate(sql);        }        catch(Exception e) {            e.printStackTrace();            return 0;        }    }        public static String changeCharset(String s, String from, String to) throws UnsupportedEncodingException {        byte[] b = s.getBytes(from);        return new String(b, to);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -