📄 sql.java
字号:
/*
* Created on 2008-12-23
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package FMJavaBean;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
/**
* @author zhou
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class Sql {
private java.sql.Connection conn;
private java.sql.Statement stmt;
private ResultSet result;
private ResultSet result1;
public void conn()
{
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/caims";
conn = DriverManager.getConnection(url,"root","111111");
stmt = conn.createStatement();
} catch (Throwable e) {
// TODO Auto-generated catch block
System.out.println(e);;
}
}
public ArrayList sqlquery(String sqlStat)
{
ArrayList al = new ArrayList();
try
{
result = stmt.executeQuery(sqlStat);
while(result.next())
{
FOrder od = new FOrder();
od.setRecord_ID(result.getString("RecordID"));
od.setFacility_ID(result.getString("FacilityID"));
od.setMember_ID(result.getString("UserName"));
od.setPayment(result.getString("Payment"));
od.setStartTime(result.getString("StartTime"));
od.setEndTime(result.getString("EndTime"));
// result1 = stmt.executeQuery("select Kind,Expense form facilityinformation where FacilityID ='"+od.getFacility_ID()+"'");
od.setKind(result.getString("Kind"));
od.setExpense(result.getString("Expense"));
od.setDate(result.getString("Date"));
od.setOrderState(result.getString("OrderState"));
al.add(od);
}
result.close();
}catch(Throwable e) {
// TODO Auto-generated catch block
System.out.println(e);
}
return al;
}
public ArrayList queryFacility(String stat)
{
ArrayList al = new ArrayList();
try{
result = stmt.executeQuery(stat);
while(result.next())
{
Facility od = new Facility();
od.setFacility_ID(result.getString("FacilityID"));
od.setKind(result.getString("Kind"));
od.setExpense(result.getString("Expense"));
od.setFacilityState(result.getString("FacilityState"));
al.add(od);
}
}catch(Throwable e){
System.out.println(e);
}
return al;
}
public ArrayList queryUser(String stat)
{
ArrayList al = new ArrayList();
try{
result = stmt.executeQuery(stat);
while(result.next())
{
UserMsg um = new UserMsg();
um.setMsgID(result.getString("RecordID"));
um.setUserName(result.getString("UserName"));
um.setMsgState("1");
um.setRealName(result.getString("RealName"));
um.setDate(result.getString("Date"));
um.setGender(result.getString("Gender"));
al.add(um);
}
}catch(Throwable e){
System.out.println(e);
}
return al;
}
public void insertFacility(String stat)
{
try{
stmt.executeUpdate(stat);
}catch(Throwable e){
System.out.println(e);
}
}
public ResultSet checkFacility(String sql)
{
try{
return stmt.executeQuery(sql);
}catch(Throwable e){
System.out.println(e);
return null;
}
}
public void close() throws SQLException
{
stmt.close();
conn.close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -