アットウィキロゴ

ひstろりんせえrt

import java.sql.*;

class historyinsert{

Double volume,hprice,lprice,cprice,oprice;
int gcode,gyear,gmonth,gday;

void makedata(String database){

String url = "jdbc:derby:db;create=true";  
String usr = "";  
String pwd = "";

Connection dbx;    
String sqx;

sqx="insert into ";
sqx=sqx+database;
sqx=sqx+"(gcode,gyear,gmonth,gday,oprice,hprice,lprice,cprice,volume) values (?,?,?,?,?,?,?,?,?)";

try {
dbx = DriverManager.getConnection(url, usr, pwd);  
PreparedStatement pstmt = dbx.prepareStatement(sqx);
pstmt.setInt(1, gcode);
pstmt.setInt(2,gyear);  
pstmt.setInt(3, gmonth);
pstmt.setInt(4, gday);
pstmt.setDouble(5, oprice);
pstmt.setDouble(6, hprice);
pstmt.setDouble(7, lprice);
pstmt.setDouble(8, cprice);  
pstmt.setDouble(9, volume);  

int nu = pstmt.executeUpdate();

dbx.close();

}catch (SQLException e){System.out.println("SQLException:" + e.getMessage());}

}

}
最終更新:2011年04月03日 03:34