📄 jdbc.java
字号:
{
int_year = int_year + 1;
int_mon = 0;
}
else
{
int_mon++;
}
}
Object[] objs = {new Integer(int_year),new Integer(int_mon+1)};
rtnStr = MessageFormat.format("VPW_{0,number,0000}{1,number,00}",objs);
return rtnStr;
}
public String getVpwTable(int startDay,String byDate)
{
String rtnStr = "";
int int_year = 0;
int int_mon = 0;
int int_day = 0;
int_year = Integer.parseInt(byDate.substring(0,4));
int_mon = Integer.parseInt(byDate.substring(5,7));
int_day = Integer.parseInt(byDate.substring(8,10));
if(int_year==0||int_mon==0||int_day==0)
return "dateFormat error!";
if( int_day >= startDay && startDay > 1 )
{
if( int_mon >= 12 ) // months=12 DECEMBER
{
int_year = int_year + 1;
int_mon = 1;
}
else
{
int_mon++;
}
}
Object[] objs = {new Integer(int_year),new Integer(int_mon)};
rtnStr = MessageFormat.format("VPW_{0,number,0000}{1,number,00}",objs);
return rtnStr;
}
public String getOtwTable(int startDay)
{
String rtnStr = "";
int int_year = 0;
int int_mon = 0;
int int_day = 0;
Calendar now = Calendar.getInstance();
int_year = now.get(Calendar.YEAR);
int_mon = now.get(Calendar.MONTH);
int_day = now.get(Calendar.DAY_OF_MONTH);
if( int_day >= startDay && startDay > 1 )
{
if( int_mon >= 11 ) // months=12 DECEMBER
{
int_year = int_year + 1;
int_mon = 0;
}
else
{
int_mon++;
}
}
Object[] objs = {new Integer(int_year),new Integer(int_mon+1)};
rtnStr = MessageFormat.format("OTW_{0,number,0000}{1,number,00}",objs);
return rtnStr;
}
public String getOtwTable(int startDay,String byDate)
{
String rtnStr = "";
int int_year = 0;
int int_mon = 0;
int int_day = 0;
int_year = Integer.parseInt(byDate.substring(0,4));
int_mon = Integer.parseInt(byDate.substring(5,7));
int_day = Integer.parseInt(byDate.substring(8,10));
if(int_year==0||int_mon==0||int_day==0)
return "dateFormat error!";
if( int_day >= startDay && startDay > 1 )
{
if( int_mon >= 12 ) // months=12 DECEMBER
{
int_year = int_year + 1;
int_mon = 1;
}
else
{
int_mon++;
}
}
Object[] objs = {new Integer(int_year),new Integer(int_mon)};
rtnStr = MessageFormat.format("OTW_{0,number,0000}{1,number,00}",objs);
return rtnStr;
}
public String createAllView(int startDay) throws Exception
{
String rtnStr = "";
CallableStatement cstmt=null;
jdbc myJdbc=new jdbc();
myJdbc.getConn();
try
{
cstmt=myJdbc.conn.prepareCall("{call create_view_all(?)}");
cstmt.registerOutParameter(1,java.sql.Types.VARCHAR);
cstmt.execute();
rtnStr=cstmt.getString(1);
cstmt.close();
}
catch(Exception e)
{
System.out.println(e);
cstmt.close();
rtnStr="createAllView() execute error!";
}
myJdbc.closeConn();
return rtnStr;
}
public String createMonView(String dt1, String dt2, int startDay) throws Exception
{
String rtnStr = "";
CallableStatement cstmt=null;
if(comTime(dt1,dt2)<0)
return "The format of dtime is error!";
jdbc myJdbc=new jdbc();
myJdbc.getConn();
try
{
cstmt=myJdbc.conn.prepareCall("{call create_obs_view(?,?,?)}");
cstmt.setString(1,dt1);
cstmt.setString(2,dt2);
cstmt.registerOutParameter(3,java.sql.Types.VARCHAR);
cstmt.execute();
rtnStr=cstmt.getString(3);
rtnStr=rtnStr.replaceFirst("ALLOBS_","REPOBS_");
cstmt.close();
}
catch(Exception e)
{
System.out.println(e);
cstmt.close();
rtnStr="createMonView execute error!";
}
myJdbc.closeConn();
return rtnStr;
}
public String getMaxPartmentId(String user_type,String style,String area_code,String exch_id)
{
String group_style="",group_user_type="",group_area_code="",group_id="",group_bureau_id="";
String ls_sql="";
if(exch_id==null) exch_id="";
if(exch_id.equals("")) return "";
ls_sql=" select group_id,user_type,bureau_id,styletype,area_code from grouplogin,group_level"+
" where group_id <=stop_id"+
" and group_id >=start_id"+
" and (accept_obstacle_tyle is null or accept_obstacle_tyle <> '1') "+
" and area_code="+area_code+
" and (( ','||bureau_id||',' like '%,"+exch_id+",%') "+
" or ((bureau_id is null or bureau_id='')))" +
" and (( ','||styletype||',' like '%,"+style+",%') "+
" or ((styletype is null or styletype='')))" +
" order by group_id desc ";
jdbc myJdbc=new jdbc();
myJdbc.getConn();
try
{
myJdbc.rs=myJdbc.stmt.executeQuery(ls_sql);
while(myJdbc.rs.next())
{
group_bureau_id=myJdbc.rs.getString("bureau_id");
group_area_code=myJdbc.rs.getString("area_code");
group_user_type=myJdbc.rs.getString("user_type");
group_id=myJdbc.rs.getString("group_id");
group_style=myJdbc.rs.getString("styletype");
if(group_bureau_id==null) group_bureau_id="";
if(group_user_type==null) group_user_type="";
if(group_style==null) group_style="";
if(!group_user_type.equals(""))
group_user_type=","+group_user_type+",";
if(!group_style.equals(""))
group_style=","+group_style+",";
if(!group_style.equals(""))
{
if(group_style.indexOf(style)>=0)
{
if(!group_user_type.equals(""))
{
if(group_user_type.indexOf(user_type)>=0)
{
myJdbc.closeConn();
return group_id;
}
}
else
{
myJdbc.closeConn();
return group_id;
}
}
}
else
{
if(!group_user_type.equals(""))
{
if(group_user_type.indexOf(user_type)>=0)
{
myJdbc.closeConn();
return group_id;
}
}
else
{
myJdbc.closeConn();
return group_id;
}
}
}
myJdbc.closeConn();
}
catch(Exception e)
{
myJdbc.closeConn();
System.out.println(ls_sql+e);
return null;
}
return group_id;
}
public String getPartmentId(String user_type,String style,String area_code,String exch_id)
{
String group_style="",group_user_type="",group_area_code="",group_id="",group_bureau_id="";
String ls_sql="";
String all_group_id="";
if(exch_id==null) exch_id="";
if(exch_id.equals("")) return "";
ls_sql=" select group_id,user_type,bureau_id,styletype,area_code from grouplogin,group_level"+
" where group_id <=stop_id"+
" and group_id >=start_id"+
" and group_level >=4 "+
" and (accept_obstacle_tyle is null or accept_obstacle_tyle <> '1') "+
" and (( ','||bureau_id||',' like '%,"+exch_id+",%') "+
" or (area_code="+area_code+" and (bureau_id is null or bureau_id='')))" +
" order by styletype";
jdbc myJdbc=new jdbc();
myJdbc.getConn();
try
{
myJdbc.rs=myJdbc.stmt.executeQuery(ls_sql);
while(myJdbc.rs.next())
{
group_bureau_id=myJdbc.rs.getString("bureau_id");
group_area_code=myJdbc.rs.getString("area_code");
group_user_type=myJdbc.rs.getString("user_type");
group_id=myJdbc.rs.getString("group_id");
group_style=myJdbc.rs.getString("styletype");
if(group_bureau_id==null) group_bureau_id="";
if(group_user_type==null) group_user_type="";
if(group_style==null) group_style="";
if(!group_user_type.equals(""))
group_user_type=","+group_user_type+",";
if(!group_style.equals(""))
group_style=","+group_style+",";
if(!group_style.equals(""))
{
if(group_style.indexOf(style)>=0)
{
if(!group_user_type.equals(""))
{
if(group_user_type.indexOf(user_type)>=0)
{
all_group_id+=","+group_id;
}
}
else
{
all_group_id+=","+group_id;
}
}
}
else
{
if(!group_user_type.equals(""))
{
if(group_user_type.indexOf(user_type)>=0)
{
all_group_id+=","+group_id;
}
}
else
{
all_group_id+=","+group_id;
}
}
}
myJdbc.closeConn();
}
catch(Exception e)
{
myJdbc.closeConn();
System.out.println(ls_sql+e);
return null;
}
return all_group_id;
}
public String getCheckerSid( String test_number, int cmd, String error_style ) throws Exception
{
String checker_id=null;
CallableStatement cstmt=null;
jdbc myJdbc=new jdbc();
myJdbc.getConn();
try
{
cstmt=myJdbc.conn.prepareCall("{call ?:=getchkid_bypho(?, ?, ?)}");
cstmt.registerOutParameter(1,java.sql.Types.VARCHAR);
cstmt.setString(2,test_number);
cstmt.setString(3,error_style);
cstmt.setInt(4,cmd);
cstmt.execute();
checker_id=cstmt.getString(1);
cstmt.close();
}
catch(Exception e)
{
System.out.println(e);
cstmt.close();
checker_id=null;
}
myJdbc.closeConn();
return checker_id;
}
public void setConnectcountInc()
{
connectCount++;
System.out.println(getTime()+" 目前所用连接的数量为:"+connectCount);
}
public void setConnectcountDec()
{
connectCount--;
System.out.println(getTime()+" 目前所用连接的数量为:"+connectCount);
}
public static void main(String arg[])
{
jdbc jdbc=new jdbc();
System.out.println(jdbc.getTime());
System.out.println(jdbc.format("000",1));
System.out.println(jdbc.format("-000",1));
System.out.println(jdbc.format("000.00",1));
System.out.println(jdbc.format("##,###.##",123456.789));
System.out.println(jdbc.format("$.##",1.039));
System.out.println(jdbc.format("¥.##元",1.039));
System.out.println(jdbc.getObsTable(21));
System.out.println(jdbc.getDupTable(21));
System.out.println(jdbc.getRepTable(21));
System.out.println(jdbc.getObsTable(21,"2003/12/01"));
System.out.println(jdbc.getDupTable(21,"2003/12/21"));
System.out.println(jdbc.getRepTable(21,"2003/12/25"));
System.out.println("2000-03-21-2000-03-21:"+jdbc.comTime("2000-03-21 00:00:59","2000-03-21 00:00:59"));
System.out.println("2000/03/21-2000/03/21:"+jdbc.comTime("2000/03/21","2000/03/21"));
System.out.println("2000/03/21-2000/04/21:"+jdbc.comTime("2000/03/21","2000/04/21"));
System.out.println("2000/03/21-2000/05/21:"+jdbc.comTime("2000/03/21","2000/05/21"));
System.out.println("2000/03/01-2000/03/09:"+jdbc.comTime("2000/03/01","2000/03/09"));
System.out.println("2001/02/28-2002/03/30:"+jdbc.comTime("2001/02/28","2002/03/30"));
System.out.println("2001/02/29-2002/03/30:"+jdbc.comTime("2001/02/29","2002/03/30"));
System.out.println("2000/02/29-2000/03/30:"+jdbc.comTime("2000/02/29","2000/03/30"));
System.out.println("2002/02/01-2000/03/32:"+jdbc.comTime("2002/02/01","2000/03/32"));
System.out.println("2000/02/01-2000/03-30:"+jdbc.comTime("2002/02/01","2000/03-30"));
System.out.println("2000/02/01-2000/3/30:"+jdbc.comTime("2002/02/01","2000/3/30"));
System.out.println(jdbc.getRepTime("2004-03-20 06:41:10",18.0));
System.out.println(jdbc.getDatebaseType());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -