TERADATA with JAVA in Teradata


Connecting Teradata with JAVA:

Pre-requisites: Teradata JDBC driver (Available in Teradata website)

General syntax:

1. Establishing connection
private void buildCon() 
{
try 
{
Class.forName("com.ncr.teradata.TeraDriver");
con = DriverManager.getConnection(serverURL, username, password);
} 
catch (Exception e) 
{
e.printStackTrace();
}
}


2. Execute query
Statement st = con.createStatement();
ResultSet rset = null;
String sql = "Your query !!!";
rset = st.executequery(sql);


3. Close connection
private void closeCon()
{
if(con != null)
{
try 
{
this.con.close();
} 
catch (SQLException e) 
{
e.printStackTrace(); 
}
}


..