アットウィキロゴ

いんせrtだた

import java.sql.*;

class insertdata{

double oprice[]=new double[100];
double hprice[]=new double[100];
double lprice[]=new double[100];
double cprice[]=new double[100];
double volume[]=new double[100];
int year[]=new int[100];
String month[]=new String[100];
int day[]=new int[100];
int ccode;
String name;
int num;

void makedata(String database,int num,int s){

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

Connection dbx;    
String sqx;

sqx="insert into ";
sqx=sqx+database;
sqx=sqx+"(num,name,ccode,nyear,month,day,oprice,hprice,lprice,cprice,volume) values (?,?,?,?,?,?,?,?,?,?,?)";

try {
dbx = DriverManager.getConnection(url, usr, pwd);  
PreparedStatement pstmt = dbx.prepareStatement(sqx);
pstmt.setInt(1, num);
pstmt.setString(2,name);  
pstmt.setInt(3, ccode);
pstmt.setInt(4, year[s]);
pstmt.setString(5,month[s]);  
pstmt.setInt(6, day[s]);
pstmt.setDouble(7, oprice[s]);
pstmt.setDouble(8, hprice[s]);
pstmt.setDouble(9, lprice[s]);
pstmt.setDouble(10, cprice[s]);
pstmt.setDouble(11, volume[s]);

int nu = pstmt.executeUpdate();

dbx.close();

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

}

}
最終更新:2011年03月30日 10:41