📄 condb.java
字号:
package Condb;
import java.sql.*;
import java.lang.*;
import java.io.*;
public class Condb{
public String dbname="jdbc:mysql://localhost:3306/wjl?useUnicode=true&characterEncoding=gbk";
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
private String User="root";
private String Pass="lenovo";
public Condb(){
try{
Class.forName("org.gjt.mm.mysql.Driver");
}catch(ClassNotFoundException e1){
System.out.print(e1);
}try{
con=DriverManager.getConnection(dbname,User,Pass);
}catch(SQLException e3){
System.err.print(e3);}
}
public ResultSet executeQuery(String sql)
{
try{
stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(sql);
}catch(SQLException e2){
System.err.print(e2);
}
return rs;
}
public int executeUpdate(String sql)
{
int rt=0;
try{
stmt=con.createStatement();
rt=stmt.executeUpdate(sql);
}catch(SQLException ex)
{
System.err.print(ex);
}
return rt;
}
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.print(e);}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -