📄 investcorpdb.java
字号:
package server;
import java.sql.*;
import java.util.StringTokenizer;
public class InvestCorpdb extends database{
InvestCorpdb(String strDBName,String id,String pw){
super(strDBName,id,pw);
}
boolean isExist() throws SQLException
{
if(rs.next())
return true;
else
return false;
}
void QueryData(String strMeg1,int kind)
{
String strsqlQuery="";
if(kind==1)
{
strsqlQuery="select * from Application where 投资公司='"+strMeg1+"'";
}
if(kind==2)
{
strsqlQuery="select * from Application ";
}
if(kind==3)
{
strsqlQuery="select * from Application where 申请公司='"+strMeg1+"'";
}
if(kind==4)
{
strsqlQuery="select * from Item where 中标公司='"+strMeg1+"'";
}
if(kind==5)
{
strsqlQuery="select * from Application where 项目名='"+strMeg1+"'";
}
try {
rs=sql.executeQuery(strsqlQuery);
} catch (SQLException e) {
e.printStackTrace();
}
}
void InsertNew(String strMeg,int kind )
{
if(kind==1)
{
StringTokenizer stn = new StringTokenizer(strMeg, "/");
String[] temp = new String[3];
int i = 0;
while (stn.hasMoreTokens()) {
temp[i] = stn.nextToken();
i++;
}
String strsqlInsert="insert into Application (项目名,投资公司,申请公司,目前最低金额)values('"
+temp[0]+"','"+temp[2]+"','无',"+Float.valueOf(temp[1])+")";
System.out.println(strsqlInsert);
try {
sql.executeUpdate(strsqlInsert);
} catch (SQLException e) {
e.printStackTrace();
}
}
if(kind==2)
{
StringTokenizer stn = new StringTokenizer(strMeg, "/");
String[] temp = new String[4];
int i = 0;
while (stn.hasMoreTokens()) {
temp[i] = stn.nextToken();
i++;
}
String strsqlInsert="insert into Item (项目名,投资公司,中标公司,总投资)values('"
+temp[0]+"','"+temp[1]+"','"+temp[2]+"',"+Float.valueOf(temp[3])+")";
try {
sql.executeUpdate(strsqlInsert);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
void Delete(String strMeg,int kind)
{
if(kind==1)
{
StringTokenizer stn = new StringTokenizer(strMeg, "/");
String[] temp = new String[4];
int i = 0;
while (stn.hasMoreTokens()) {
temp[i] = stn.nextToken();
i++;
}
String strsqlDelete="delete from Application where 项目名='"+temp[0]+"' and 投资公司='"+temp[1]+"'";
try {
sql.executeUpdate(strsqlDelete);
} catch (SQLException e) {
e.printStackTrace();
}
}
if(kind==2)
{
StringTokenizer stn = new StringTokenizer(strMeg, "/");
String[] temp = new String[2];
int i = 0;
while (stn.hasMoreTokens()) {
temp[i] = stn.nextToken();
i++;
}
String strsqlDelete="delete from Item where 中标公司='"+temp[0]+"' and 项目名='"+temp[1]+"'";
try {
sql.executeUpdate(strsqlDelete);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
void updatedata(String strComp,int money) throws SQLException
{
rs.absolute(1);
rs.updateObject("申请公司",strComp);
rs.updateObject("目前最低金额",money);
rs.updateRow();
}
Item GetInfo2(int kind)
{
Item strMeg=new Item(null,0,null,null);
try {
if(kind==1)
{
strMeg.setlMoney(rs.getLong("目前最低金额"));
strMeg.setstrComp(rs.getString("申请公司"));
}
if(kind==2)
{
strMeg.setlMoney(rs.getLong("总投资"));
strMeg.setstrComp(rs.getString("中标公司"));
}
strMeg.setName(rs.getString("项目名"));
strMeg.setstrInvest(rs.getString("投资公司"));
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return strMeg;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -