Quantcast
Viewing all articles
Browse latest Browse all 445

Connecting to Teradata is very solwly(5 sec)

That's my code below, I connected to Teradata used java JDBC but It took 5 sec to do "stmt = conn.createStatement();".

Could anyone help me to fix this problem?

 

 

 

CODE

public class dw_targetmonthjdbc {

 

List<dw_targetmonth> tmList = new ArrayList<dw_targetmonth>();

 

public List<dw_targetmonth> tmjdbc() throws ClassNotFoundException {

Connection conn = null;

Statement stmt = null;

try {

 

String connurl="jdbc:teradata://192.168.206.1";

Class.forName("com.teradata.jdbc.TeraDriver");

conn=DriverManager.getConnection(connurl, "dwauto", "dwauto");

 

stmt = conn.createStatement();

 

String strSelect ="select A.* FROM dw_targetmonth A inner join (SELECT  monthcode, Max(DTLDate) as dtldate FROM dw_targetmonth GROUP BY monthcode) B on A.monthcode=B.monthcode and A.dtldate=B.dtldate";

 

ResultSet rset = stmt.executeQuery(strSelect);

 

System.out.println("The records selected are:");

int rowCount = 0;

 

while (rset.next()) { 

dw_targetmonth tmsc = new dw_targetmonth();

tmsc.setMonthcode(rset.getString("monthcode"));

tmsc.setTargetmonthstore(rset.getDouble("targetmonthstore"));

tmsc.setDtldate(rset.getDate("dtldate"));

 

tmList.add(tmsc);

}

 

} catch (SQLException ex) {

ex.printStackTrace();

} finally {

 

try {

if (stmt != null)

stmt.close(); // This closes ResultSet too

if (conn != null)

conn.close();

} catch (SQLException ex) {

ex.printStackTrace();

}

}

return tmList;

 

}

 

}

 

Forums: 

Viewing all articles
Browse latest Browse all 445

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>