Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BancoDeDados {
- private Connection connection;
- /**
- * inicia o banco
- */
- public void iniciar() {
- try {
- Class.forName("org.hsqldb.jdbcDriver");
- String url = "jdbc:hsqldb:file:target/bancoDeTeste";
- String username = "sa";
- String password = "";
- connection = DriverManager.getConnection(url, username, password);
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- /**
- * termina o banco de dados.
- */
- public void terminar() {
- try {
- connection.createStatement().execute("SHUTDOWN");
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- /**
- * Obtem a connection usada para o banco.
- *
- * @return
- */
- public Connection getConnection() {
- return connection;
- }
- }
Add Comment
Please, Sign In to add comment