📄 dbtools.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 + -