diff --git a/com.oracle.truffle.r.engine/oracle.config b/com.oracle.truffle.r.engine/oracle.config index b49e79d8cbbd5096f744aea3ce597c3b68a250e6..676cc848c308c0a9303477005ca673d05b3017a8 100644 --- a/com.oracle.truffle.r.engine/oracle.config +++ b/com.oracle.truffle.r.engine/oracle.config @@ -1,5 +1,5 @@ -ora.host = myoracle.com -ora.sid = myview -ora.port = 7658 -ora.user = julilope -ora.passwd = AVONEJ$sartec3 +host = myoracle.com +sid = myview +port = 7658 +user = julilope +passwd = Pa$$w0rd diff --git a/com.oracle.truffle.r.engine/postgre.config b/com.oracle.truffle.r.engine/postgre.config index e0fd54220004434f43609a593cd2742976a62f94..39dd278151eb10c99d66e7b091e5d6c342b355b4 100644 --- a/com.oracle.truffle.r.engine/postgre.config +++ b/com.oracle.truffle.r.engine/postgre.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = postgres -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = postgres +port = 5432 +user = julien +passwd = Pa$$w0rd diff --git a/com.oracle.truffle.r.engine/postgre2.config b/com.oracle.truffle.r.engine/postgre2.config index 2c7bf365357d7ebc332e3c58037ae417bce07bed..8ef8ed55fbf64fc1ac673aa5f1ce3e526d6fb55f 100644 --- a/com.oracle.truffle.r.engine/postgre2.config +++ b/com.oracle.truffle.r.engine/postgre2.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = other -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = other +port = 5432 +user = julien +passwd = Pa$$w0rd diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java index f11bee2785ac4a5cfbfe534b514e2aef531b0fd1..9f9bf3485d13442d5ef0e167520c7cdc6395d5c1 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/qirinterface/QIRInterface.java @@ -22,16 +22,11 @@ */ package com.oracle.truffle.r.nodes.qirinterface; -import java.io.FileReader; -import java.io.IOException; -import java.io.Reader; import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Properties; - import com.oracle.truffle.api.frame.Frame; import com.oracle.truffle.api.frame.FrameDescriptor; import com.oracle.truffle.api.frame.FrameSlot; @@ -48,16 +43,10 @@ import com.oracle.truffle.r.runtime.env.REnvironment; import qir.ast.*; import qir.ast.data.*; import qir.ast.expression.*; -import qir.driver.sql.OracleDriver; -import qir.driver.sql.PostgreSQLDriver; -import qir.driver.ConnectionData; import qir.driver.DBDriver; import qir.driver.QIRDriver; -import qir.driver.hbase.HBaseDriver; public final class QIRInterface { - private static final Map<String, DBDriver<?, ?>> driverCache = new HashMap<>(); - /** * Runs a query in the database pointed by the given driver and returns the results. * @@ -124,65 +113,10 @@ public final class QIRInterface { } /** - * Returns a {@link DBDriver} of a database using a configuration file. This function uses a - * cache for the drivers. - * - * @param dbName The name of the targeted database - * @param fileName The name of the configuration file - * @return A {@link DBDriver} to the given database with the given configuration - */ - public static final DBDriver<?, ?> createDriver(final String dbName, final String fileName) throws UnsupportedOperationException { - final String cacheKey = dbName + '@' + fileName; - DBDriver<?, ?> result = driverCache.get(cacheKey); - - if (result != null) - return result; - switch (dbName) { - case "Oracle": - result = new OracleDriver(createConnectionData("ora", fileName)); - break; - case "PostgreSQL": - result = new PostgreSQLDriver(createConnectionData("pgsql", fileName)); - break; - case "HBase": - result = new HBaseDriver(fileName); - break; - default: - throw new RuntimeException("Unknown database: " + dbName); - } - driverCache.put(cacheKey, result); - return result; - } - - /** - * This function closes the connection of drivers created with the function - * {@link #createDriver(String, String)}. + * This function closes the connection of database drivers. */ public static final void closeDrivers() { - driverCache.values().stream().forEach(driver -> driver.closeConnection()); - } - - /** - * Creates a {@link ConnectionData} object based on the given configuration file. - * - * @param prefix A prefix for properties in the configuration file - * @param fileName The name of the configuration file - * @return A {@link ConnectionData} created from the given configuration file - */ - private static final ConnectionData createConnectionData(final String prefix, final String fileName) { - try { - final Reader dbConfigReader = new FileReader(fileName); - final Properties p = new Properties(); - p.load(dbConfigReader); - final String sessionId = p.getProperty(prefix + ".sid"); - final String serverName = p.getProperty(prefix + ".host"); - final int port = Integer.parseInt(p.getProperty(prefix + ".port")); - final String userName = p.getProperty(prefix + ".user"); - final String passwd = p.getProperty(prefix + ".passwd"); - return new ConnectionData(sessionId, serverName, port, userName, passwd); - } catch (IOException e) { - throw new RuntimeException("Invalid configuration file for connection to a database: " + fileName); - } + DBDriver.closeDrivers(); } /** diff --git a/com.oracle.truffle.r.test/oracle.config b/com.oracle.truffle.r.test/oracle.config index b49e79d8cbbd5096f744aea3ce597c3b68a250e6..676cc848c308c0a9303477005ca673d05b3017a8 100644 --- a/com.oracle.truffle.r.test/oracle.config +++ b/com.oracle.truffle.r.test/oracle.config @@ -1,5 +1,5 @@ -ora.host = myoracle.com -ora.sid = myview -ora.port = 7658 -ora.user = julilope -ora.passwd = AVONEJ$sartec3 +host = myoracle.com +sid = myview +port = 7658 +user = julilope +passwd = Pa$$w0rd diff --git a/com.oracle.truffle.r.test/postgre.config b/com.oracle.truffle.r.test/postgre.config index e0fd54220004434f43609a593cd2742976a62f94..39dd278151eb10c99d66e7b091e5d6c342b355b4 100644 --- a/com.oracle.truffle.r.test/postgre.config +++ b/com.oracle.truffle.r.test/postgre.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = postgres -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = postgres +port = 5432 +user = julien +passwd = Pa$$w0rd diff --git a/com.oracle.truffle.r.test/postgre2.config b/com.oracle.truffle.r.test/postgre2.config index 2c7bf365357d7ebc332e3c58037ae417bce07bed..8ef8ed55fbf64fc1ac673aa5f1ce3e526d6fb55f 100644 --- a/com.oracle.truffle.r.test/postgre2.config +++ b/com.oracle.truffle.r.test/postgre2.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = other -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = other +port = 5432 +user = julien +passwd = Pa$$w0rd diff --git a/oracle.config b/oracle.config index b49e79d8cbbd5096f744aea3ce597c3b68a250e6..676cc848c308c0a9303477005ca673d05b3017a8 100644 --- a/oracle.config +++ b/oracle.config @@ -1,5 +1,5 @@ -ora.host = myoracle.com -ora.sid = myview -ora.port = 7658 -ora.user = julilope -ora.passwd = AVONEJ$sartec3 +host = myoracle.com +sid = myview +port = 7658 +user = julilope +passwd = Pa$$w0rd diff --git a/postgre.config b/postgre.config index e0fd54220004434f43609a593cd2742976a62f94..39dd278151eb10c99d66e7b091e5d6c342b355b4 100644 --- a/postgre.config +++ b/postgre.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = postgres -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = postgres +port = 5432 +user = julien +passwd = Pa$$w0rd diff --git a/postgre2.config b/postgre2.config index 2c7bf365357d7ebc332e3c58037ae417bce07bed..8ef8ed55fbf64fc1ac673aa5f1ce3e526d6fb55f 100644 --- a/postgre2.config +++ b/postgre2.config @@ -1,5 +1,5 @@ -pgsql.host = localhost -pgsql.sid = other -pgsql.port = 5432 -pgsql.user = julien -pgsql.passwd = Pa$$w0rd +host = localhost +sid = other +port = 5432 +user = julien +passwd = Pa$$w0rd