📄 producedb.java
字号:
package qyxx;
import java.sql.*;
import java.util.*;
public class produceDB
{
String DBDriver = "oracle.jdbc.driver.OracleDriver";
String DBUrl = "jdbc:oracle:thin:@localhost:1521:ORACLE";
String DBUser = "jerry";
String DBPsw = "123456";
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
private Connection initDB()
{
try
{
Class.forName(DBDriver);
return DriverManager.getConnection(DBUrl,DBUser,DBPsw);
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
public ArrayList getMoneyInfo()
{
ArrayList list = new ArrayList();
try
{
String sql = "select * from QYXX_MONEY order by money_time";
this.conn = null;
conn = this.initDB();
this.stmt = null;
this.stmt = conn.prepareStatement(sql);
rs = this.stmt.executeQuery();
while(rs.next())
{
// moneyTable mt = new moneyTable();
// mt.setMoneytime(rs.getString("money_time"));
// mt.setMount(rs.getString("mount"));
// mt.setJiedai(rs.getString("jiedai"));
// mt.setMoneyman(rs.getString("money_men"));
// mt.setMoneypriority(rs.getString("money_priority"));
// mt.setDepartid(String.valueOf(rs.getInt("depart_id")));
// list.add(mt);
}
return list;
}
catch (Exception e)
{
e.printStackTrace();
return list;
}
finally
{
try
{
conn.close();
stmt.close();
rs.close();
}
catch(Exception e)
{
}
}
}
public int addProduce(qyxx.produceTable ptable)
{
try
{
this.conn = null;
conn = this.initDB();
String sql = "select MAX(id) from QYXX_PRODUCE";
this.stmt = null;
this.stmt = conn.prepareStatement(sql);
int d = 0;
rs = stmt.executeQuery();
if(rs.next())
{
d = rs.getInt(1) + 1;
}
sql = "insert into QYXX_PRODUCE(id,good_id,produce_mount,produce_men,produce_time,priority) values(?,?,?,?,?,?)";
this.stmt = null;
this.stmt = conn.prepareStatement(sql);
stmt.setInt(1,d);
stmt.setString(2,ptable.getGoodid());
stmt.setInt(3,Integer.parseInt(ptable.getProducemount()));
stmt.setString(4,ptable.getProduceman());
stmt.setString(5,ptable.getProducetime());
stmt.setString(6,ptable.getPriority());
this.stmt.executeUpdate();
return 1;
}
catch (Exception e)
{
e.printStackTrace();
return 0;
}
finally
{
try
{
rs.close();
conn.close();
stmt.close();
}
catch(Exception e)
{
}
}
}
public int editProduce(qyxx.produceTable ptable)
{
try
{
this.conn = null;
conn = this.initDB();
String sql = "update QYXX_PRODUCE set produce_mount = ?, good_id= ? where id = ?";
this.stmt = null;
this.rs = null;
this.stmt = conn.prepareStatement(sql);
stmt.setInt(1,Integer.parseInt(ptable.getProducemount()));
stmt.setInt(2,Integer.parseInt(ptable.getGoodid()));
stmt.setInt(3,Integer.parseInt(ptable.getId()));
stmt.executeUpdate();
return 1;
}
catch (Exception e)
{
e.printStackTrace();
return 0;
}
finally
{
try
{
conn.close();
stmt.close();
rs.close();
}
catch(Exception e)
{
}
}
}
public int deleteProduce(String [] id)
{
try
{
this.conn = null;
conn = this.initDB();
for(int i=0; i<id.length; i++)
{
String sql = "delete from QYXX_Produce where id = "+id[i]+"";
this.stmt = null;
this.stmt = conn.prepareStatement(sql);
this.stmt.executeUpdate();
}
return 1;
}
catch (Exception e)
{
e.printStackTrace();
return 0;
}
finally
{
try
{
conn.close();
stmt.close();
}
catch(Exception e)
{
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -