Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
dkapoor committed Dec 18, 2013
2 parents 36cab92 + 79ab550 commit 89630a4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 23 deletions.
Binary file added lib/jtds-1.2.5.jar
Binary file not shown.
15 changes: 6 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.2.4</version>
</dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.2.5</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jtds-1.2.5.jar</systemPath>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
Expand Down Expand Up @@ -182,11 +184,6 @@
<artifactId>mysql-connector-java</artifactId>
<version>5.1.17</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr</artifactId>
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/edu/isi/karma/util/AbstractJDBCUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public abstract ArrayList<ArrayList<String>> getDataForLimitedRows(DBType dbType

public abstract ArrayList<String> getListOfTables(Connection conn) throws SQLException, ClassNotFoundException;

public Connection getConnection(String driver, String connectString) throws SQLException, ClassNotFoundException {
protected Connection getConnection(String driver, String connectString) throws SQLException, ClassNotFoundException {
Connection localConn = null;
Class.forName(driver);
localConn = DriverManager.getConnection(connectString);
Expand Down Expand Up @@ -92,18 +92,15 @@ protected String getConnectString (String hostname, int portnumber, String usern
public ArrayList<String> getListOfTables(DBType dbType, String hostname,
int portnumber, String username, String password, String dBorSIDName)
throws SQLException, ClassNotFoundException {
String connectString = getConnectString(hostname, portnumber, username, password, dBorSIDName);
Connection conn = getConnection(getDriver(), connectString);

Connection conn = getConnection(hostname, portnumber, username, password, dBorSIDName);
return getListOfTables(conn);
}

public ArrayList<ArrayList<String>> getDataForTable(DBType dbType, String hostname,
int portnumber, String username, String password, String tableName, String dBorSIDName)
throws SQLException, ClassNotFoundException {
String connectString = getConnectString(hostname, portnumber, username, password, dBorSIDName);
Connection conn = getConnection(getDriver(), connectString);


Connection conn = getConnection(hostname, portnumber, username, password, dBorSIDName);
return getDataForTable(conn, tableName);
}

Expand Down
38 changes: 32 additions & 6 deletions src/main/java/edu/isi/karma/util/SybaseUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class SybaseUtil extends AbstractJDBCUtil {

private static Logger logger = LoggerFactory
.getLogger(SybaseUtil.class);

static final String DRIVER =
"net.sourceforge.jtds.jdbc.Driver";

static final String CONNECT_STRING_TEMPLATE =
"jdbc:jtds:sybase://host:port/dbname?user=username&password=pwd";
"jdbc:jtds:sybase://host:port/dbname";


@Override
protected String getDriver() {
Expand All @@ -28,6 +34,27 @@ protected String getConnectStringTemplate() {
return CONNECT_STRING_TEMPLATE;
}

public Connection getConnection(String driver, String url, String username, String pwd) throws SQLException, ClassNotFoundException {
Connection localConn = null;
Class.forName(driver);
localConn = DriverManager.getConnection(url, username, pwd);
return localConn;
}


public Connection getConnection(String hostname,
int portnumber, String username, String password, String dBorSIDName)
throws SQLException, ClassNotFoundException {
String connectString = getConnectStringTemplate();
connectString = connectString.replaceAll("host", hostname);
connectString = connectString.replaceAll("port", Integer.toString(portnumber));
connectString = connectString.replaceAll("dbname", dBorSIDName);

logger.info("Connect to:"+ connectString);
Connection conn = getConnection(getDriver(), connectString, username, password);
return conn;
}

@Override
public ArrayList<String> getListOfTables(Connection conn)
throws SQLException, ClassNotFoundException {
Expand All @@ -45,9 +72,8 @@ public ArrayList<String> getListOfTables(Connection conn)
public ArrayList<ArrayList<String>> getDataForLimitedRows(DBType dbType,
String hostname, int portnumber, String username, String password,
String tableName, String dBorSIDName, int rowCount) throws SQLException, ClassNotFoundException {

String connectString = getConnectString(hostname, portnumber, username, password, dBorSIDName);
Connection conn = getConnection(DRIVER, connectString);

Connection conn = getConnection(hostname, portnumber, username, password, dBorSIDName);
String query = "Select * from " + tableName + " limit " + rowCount;

Statement s = conn.createStatement();
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/version.jsp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.194
v1.195

0 comments on commit 89630a4

Please sign in to comment.