📄 safelogbean.java
字号:
package com;
import java.util.ArrayList;
import java.util.Collection;
import java.sql.*;
public class SafeLogBean
{
private Connection con;
SafeLogClass safeLog;
public SafeLogBean()
{
try
{
con = DBConnection.getConnection();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void setSafeLog(SafeLogClass safeLog)
{
this.safeLog = safeLog;
}
public Collection getAllSafeLog()
{
SafeLogClass safeLog;
ArrayList arraylist = new ArrayList();
try {
Statement statement = con.createStatement();
ResultSet resultset = statement.executeQuery("select * from safeLog");
while (resultset.next())
{
safeLog = new SafeLogClass();
int i = resultset.getInt(1);
String s1 = resultset.getString(2);
String s2 = resultset.getString(3);
String s3 = resultset.getString(4);
String s4 = resultset.getString(5);
safeLog.setLogId(i);
safeLog.setUsersId(s1);
safeLog.setLandingIp(s2);
safeLog.setLandingDatetime(s3);
safeLog.setExitDatetime(s4);
arraylist.add(safeLog);
}
con.close();
}
catch (Exception e) {
e.printStackTrace();
}
return arraylist;
}
public void addSafeLog()throws Exception
{
try
{
PreparedStatement stm=con.prepareStatement("insert into safeLog values(?,?,?,?)");
stm.setString(1,safeLog.getUsersId());
stm.setString(1,safeLog.getLandingIp());
stm.setString(1,safeLog.getLandingDatetime());
stm.setString(1,safeLog.getExitDatetime());
try
{
stm.executeQuery();
}
catch(Exception e)
{
}
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -