That was my request, provide your code.
We do not need verbal explanation of what is your issue in hypothetical code, we need real code and description of problem with it
ok your right and i'm so sorry, this is my first post
here the source
the first one is LireFichier it can read thefile "CheminFichier"
import java.io.*;
import dbPKG.*;
class LireFichier
{
public LireFichier(String CheminFichier)
{
try{
FileInputStream fstream = new FileInputStream(CheminFichier);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
System.out.println (strLine);
}
in.close();
}catch (Exception e){
System.err.println("Error: " + e.getMessage());
}
}
the second one is CreateDataBase
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class CreateDataBase wich create the database "nomBase"
{
public CreateDataBase(String nomBase)
{
Connection connection = null;
Statement statement = null;
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url = "jdbc:mysql://localhost/mysql";
connection = DriverManager.getConnection(url, "root", "");
statement = connection.createStatement();
String reqSql = "CREATE DATABASE "+ nomBase;
statement.executeUpdate(reqSql);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
} // nothing we can do
}
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
} // nothing we can do
}
}
}
}
and the last one is CreateTable that create table on the database "nomBase"
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class CreateTable
{
public CreateTable(String nomBase )
{
Connection connection = null;
Statement statement = null;
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url = "jdbc:mysql://localhost/mysql";
connection = DriverManager.getConnection(url, "root", "");
statement = connection.createStatement();
String reqSql = "create table "+nomBase+".COFFEES " +
"(COF_NAME VARCHAR(32), " +
"SUP_ID INTEGER, " +
"PRICE FLOAT, " +
"SALES INTEGER, " +
"TOTAL INTEGER)";
statement.executeUpdate(reqSql);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
} // nothing we can do
}
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
} // nothing we can do
}
}
}
}
My probleme is
can I use arrylist to store the values from the text file and then execute the two other classes
or is there a best way to join all this peaces to do the necessary
i hope i was clear