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

📄 condb.java

📁 在线投票系统代码
💻 JAVA
字号:
package beans;

import java.sql.*;

public class Condb{
	String dbname="jdbc:mysql://127.0.0.1:3306/music";
	ResultSet rs=null;
	Connection con=null;
	Statement stmt=null;
	public Condb(){
		try{
				Class.forName("org.gjt.mm.mysql.Driver");
		}catch(ClassNotFoundException e1){
			System.err.println(e1);
		}try{
			con=DriverManager.getConnection(dbname);
		}catch(SQLException e3){
			System.err.print(e3);
		}
	}public ResultSet executeQuery(String sql){
		try{
			stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
			rs=stmt.executeQuery(sql);
		}catch(SQLException e2){
			System.err.print(e2);
		}
			return rs;
	}public int excuteUpdate(String sql){
		int rt=0;
		try{
			stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
			rt=stmt.executeUpdate(sql);
		}catch(SQLException ex){
			System.err.print(ex);
		}
		return rt;
	}public void close(){
		try{
			if(con!=null)
				con.close();
		}catch(Exception e){
			System.out.print(e);
		}try{
			if(rs!=null)
				rs.close();
		}catch(Exception e){
			System.out.println(e);
		}
	}
}

⌨️ 快捷键说明

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