bonsoir,
merci pour m'avoir répondu!
c'est possible de créer une table avec plusieurs champs directement dans my sql,j'ai essayé de le faire pour tester et ca a marché mais pas à travers mon code!
voici le code:
1 2 3 4 5 6 7 8 9 10
|
public void createTable(String createSql)
{try {
Statementstmt=connection.createStatement();
//connection est déja bien configurée
int nbMaj = stmt.executeUpdate(createSql);
}
catch (SQLException e) {
System.err.println("SQLException : error in creating table");}
} |
sachant que le System.out.println de createSql donne :
create table labor-neg-data (duration float, wage-increase-first-year float, wage-increase-second-year float, wage-increase-third-year float, cost-of-living-adjustment varchar(5), working-hours float, pension varchar(11), standby-pay float, shift-differential float, education-allowance varchar(4), statutory-holidays float, vacation varchar(14), longterm-disability-assistance varchar(4), contribution-to-dental-plan varchar(5), bereavement-assistance varchar(4), contribution-to-health-plan varchar(5), class varchar(5))
Dans ce cas, ca ne marche pas il ya une exception:
SQLException : error in creating table
qd la requete contient un nombre minime de champ il n'ya pa d'exception et la table est réellement créer ds une base de donnée mySql.le System.out.println de createSql ds ce cas donne :
create table cpu (MYCT float, MMIN float, MMAX float, CACH float, CHMIN float, CHMAX float, class float)
j'espere que vous pouvez me répondre!!
merci d'avance!
Partager