Add createSchema method.
This commit is contained in:
parent
38256ee921
commit
8d56607c54
2 changed files with 32 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.sikevadb;
|
package fr.devinsy.sikevadb;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
@ -33,6 +34,7 @@ import org.joda.time.DateTime;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import fr.devinsy.util.FileTools;
|
||||||
import fr.devinsy.util.StringList;
|
import fr.devinsy.util.StringList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -574,6 +576,36 @@ public class SQLSikevaDB implements SikevaDB {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates the schema (table) used by SQLSikevaDB.
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public void createSchema() throws IOException, SQLException {
|
||||||
|
//
|
||||||
|
String createCommand = FileTools.load(SQLSikevaDB.class.getResource("/fr/devinsy/sikevadb/createSchema.sql"));
|
||||||
|
|
||||||
|
//
|
||||||
|
Connection connection = null;
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
try {
|
||||||
|
//
|
||||||
|
connection = getConnection();
|
||||||
|
connection.setAutoCommit(true);
|
||||||
|
|
||||||
|
//
|
||||||
|
statement = connection.prepareStatement(createCommand);
|
||||||
|
statement.executeUpdate();
|
||||||
|
|
||||||
|
connection.commit();
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
close(connection, statement, resultSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue