I am sending also the *.dbf file i got with this new try (still cannot opened it properly in Excel :()
import java.sql.*;
import java.util.Properties;
public class MyCreateTable2 {
/**
* @param args
*/
public static void main(String[] args) {
String strDefaultOutputDir="D:/instalados/eclipse/workspaceDIVA2007_RC8/GridIO";
String strNewOutputTable="example1";
Connection conOutputFile;
Statement stOutputFile;
String strSQLCols="\"ID\" VARCHAR (25), \"NAME\" VARCHAR (25),\"VALUE\" NUMERIC (4,1)";
try {
Class.forName("com.hxtt.sql.dbf.DBFDriver").newInstance();
String urltable = "jdbc:dbf:///" + strDefaultOutputDir + "";
Properties properties = new Properties();
conOutputFile = DriverManager.getConnection(
urltable,
properties);
stOutputFile = conOutputFile.createStatement();
stOutputFile.execute("CREATE TABLE " + '"' +
strNewOutputTable + '"' + " (" + strSQLCols +
")");
stOutputFile.close();
conOutputFile.close();
stOutputFile.close();
conOutputFile.close();
}
catch (SQLException sqle) {
do {
System.out.println(sqle.getMessage());
System.out.println("Error Code:" + sqle.getErrorCode());
System.out.println("SQL State:" + sqle.getSQLState());
sqle.printStackTrace();
}
while ( (sqle = sqle.getNextException()) != null);
}
catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
|