📄 dialogkit.java~27~
字号:
package bookmanager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.sql.*;
import java.util.Vector;
public class dialogkit {//控制类
public dialogkit() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public ArrayList dialog()
{
Statement s;
ResultSet rs;
ArrayList list=new ArrayList();
dbconnection db=new dbconnection();
try {
s = db.getconnection().createStatement();
rs = s.executeQuery("select * from userinfo");
while (rs.next()) {
userinfo user=new userinfo();
user.setusername(rs.getString(1));
user.setpwd(rs.getString(2));
list.add(user);
}
} catch (SQLException ex) {
}
return list;
}
public boolean ifusernamepwd(String user,String pwd)
{
Statement sf;
ResultSet rt;
dbconnection dt=new dbconnection();
try {
sf = dt.getconnection().createStatement();
rt = sf.executeQuery("select * from userinfo where username='" +
user + "' and pwd='" + pwd + "'");
int i=0;
while(rt.next())
{
i++;
}
if(i==0)
return false;
} catch (SQLException ex) {
}
return true;
}
public boolean ifusernamepwd(String pwd)
{
Statement sf;
ResultSet rt;
dbconnection dt=new dbconnection();
try {
sf = dt.getconnection().createStatement();
rt = sf.executeQuery("select * from userinfo where pwd='" + pwd + "'");
int i=0;
while(rt.next())
{
i++;
}
if(i==0)
return false;
} catch (SQLException ex) {
}
return true;
}
public void update(String str1,String str3)
{
Statement sf;
dbconnection dt=new dbconnection();
try {
sf = dt.getconnection().createStatement();
sf.executeUpdate("update userinfo set pwd='" + str1 + "'" +
" where username='" + str3 + "'");
} catch (SQLException ex) {
}
}
public Vector vectornum(String a)
{
Statement sy;
ResultSet r;
Vector vv=new Vector();
dbconnection dtf=new dbconnection();
try {
sy = dtf.getconnection().createStatement();
r = sy.executeQuery("select * from bookinfo where bookid='"+a+"'");
while(r.next())
{
Vector v=new Vector();
for(int i=1;i<=r.getMetaData().getColumnCount();i++)
{
v.add(r.getString(i));
}
vv.add(v);
}
} catch (SQLException ex) {
}
return vv;
}
public Vector vectornumj(String ef)
{
Statement sy;
ResultSet r;
Vector vv=new Vector();
dbconnection dtf=new dbconnection();
try {
sy = dtf.getconnection().createStatement();
r = sy.executeQuery("select * from bookinfo where bookname like '%"+ef+"%'");
while(r.next())
{
Vector v=new Vector();
for(int i=1;i<=r.getMetaData().getColumnCount();i++)
{
v.add(r.getString(i));
}
vv.add(v);
}
} catch (SQLException ex) {
}
return vv;
}
public Vector vectornumber(String b)
{
Statement sy;
ResultSet r;
Vector vv=new Vector();
dbconnection dtf=new dbconnection();
try {
sy = dtf.getconnection().createStatement();
r = sy.executeQuery("select * from bookinfo where bookautor like '%"+b+"%'");
while(r.next())
{
Vector v=new Vector();
for(int i=1;i<=r.getMetaData().getColumnCount();i++)
{
v.add(r.getString(i));
}
vv.add(v);
}
} catch (SQLException ex) {
}
return vv;
}
public Vector vectornumb(String c)
{
Statement sy;
ResultSet r;
Vector vv=new Vector();
dbconnection dtf=new dbconnection();
try {
sy = dtf.getconnection().createStatement();
r = sy.executeQuery("select * from bookinfo where bookwhere like '%"+c+"%'");
while(r.next())
{
Vector v=new Vector();
for(int i=1;i<=r.getMetaData().getColumnCount();i++)
{
v.add(r.getString(i));
}
vv.add(v);
}
} catch (SQLException ex) {
}
return vv;
}
public void ifreadture(String str1,String str3,String str4,int str6,String str7,String str2,String str5,String str8)
{
Statement s;
dbconnection a=new dbconnection();
try {
s = a.getconnection().createStatement();
String tr="insert into bookinfo(bookid,bookname,bookautor,bookbalance,bookwhere,booktime,booknotes,outtime) values('"
+str1+"','"+str3+"','"+str4+"',"+str6+",'"+str7+"','"+str2+"',"+str5+",'"+str8+"'";
System.out.println(tr);
s.executeUpdate(tr);
String rt="update bookinfo onoutctrl=1 where bookid='"+str1+"'";
System.out.println(rt);
s.executeUpdate(rt);
} catch (SQLException ex) {
}
}
private void jbInit() throws Exception {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -