Package ch.epfl.lbd.database.providers.postgresql.connection.test

Source Code of ch.epfl.lbd.database.providers.postgresql.connection.test.TestPostgreSqlConnection

package ch.epfl.lbd.database.providers.postgresql.connection.test;

import java.sql.ResultSet;
import java.util.ArrayList;

import org.junit.*;

import ch.epfl.lbd.benchmark.Tester;
import ch.epfl.lbd.database.providers.postgresql.connection.PostgreSqlConnection;

public class TestPostgreSqlConnection extends Tester {
 
  @Test
  public void run()throws Exception{
   
    PostgreSqlConnection connection = new PostgreSqlConnection("src/connections.properties","connection4");
   
    try{
      //opening the database connection
      connection.openConnection();
     
      //get user tables TEST
      ArrayList<String> tbls = connection.getUserTables();
      for(String table : tbls)logger.info("Table Found: "+table);

      //select not existing table TEST
      connection.getSQLQueryResults("SELECT * FROM notexisting");
     
      //select an existing table
      ResultSet results = connection.getSQLQueryResults("SELECT * FROM spatial_ref_sys",10);
      while (results.next())logger.info(results.getString(1));
      results.close();
     
      //closing the database connection
      connection.closeConnection();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}
TOP

Related Classes of ch.epfl.lbd.database.providers.postgresql.connection.test.TestPostgreSqlConnection

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.