Netezza JDBC Program
Steps to connect to Netezza Database using Java (JDBC) program
Download the Netezza driver nzjdbc.jar
Connect to Eclipse and upload the nzjdbc.jar using "Build Path" as shown in below images
Java Class to connect to Netezza Database and read table data
---------------------------------------------------
package sample;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JdbcNetezzaConnection {
public static void main(String[] args) {
Connection conn1 = null;
Statement statement = null;
try {
Class.forName("org.netezza.Driver");
conn1 = DriverManager.getConnection("jdbc:netezza://servername/databasename", "username","password");
if (conn1 != null) {
System.out.println("Connected with connection #1");
}
// Create the statement to be used to get the results.
statement = conn1.createStatement();
// Create a query to use.
String query = "select tablename, owner from _v_table where owner = 'ADMIN' limit 10";
ResultSet resultSet = statement.executeQuery(query);
System.out.println("Printing result...");
while (resultSet.next()) {
String tn = resultSet.getString("tablename");
String opg = resultSet.getString("owner");
System.out.println("\tablename: " + tn + ", owner: " + opg );
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
if (conn1 != null && !conn1.isClosed()) {
conn1.close();
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
}
----------------------------------------------------
Output of the above class
Output from Netezza Database
Steps to connect to Netezza Database using Java (JDBC) program
Download the Netezza driver nzjdbc.jar
Connect to Eclipse and upload the nzjdbc.jar using "Build Path" as shown in below images
Java Class to connect to Netezza Database and read table data
---------------------------------------------------
package sample;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JdbcNetezzaConnection {
public static void main(String[] args) {
Connection conn1 = null;
Statement statement = null;
try {
Class.forName("org.netezza.Driver");
conn1 = DriverManager.getConnection("jdbc:netezza://servername/databasename", "username","password");
if (conn1 != null) {
System.out.println("Connected with connection #1");
}
// Create the statement to be used to get the results.
statement = conn1.createStatement();
// Create a query to use.
String query = "select tablename, owner from _v_table where owner = 'ADMIN' limit 10";
ResultSet resultSet = statement.executeQuery(query);
System.out.println("Printing result...");
while (resultSet.next()) {
String tn = resultSet.getString("tablename");
String opg = resultSet.getString("owner");
System.out.println("\tablename: " + tn + ", owner: " + opg );
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {
try {
if (conn1 != null && !conn1.isClosed()) {
conn1.close();
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
}
----------------------------------------------------
Output of the above class
Output from Netezza Database
Your blog is the best place to gain knowledge on Java programming. Keep following my profile for IT trainings and languages studies.
ReplyDeleteRegards:
java courses in chennai with placement
free java training in chennai
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeletepython training in sholinganallur
python training in annanagar
python training in chennai
python training in marathahalli
python training in btm layout
python training in rajaji nagar
python training in jayanagar
Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
ReplyDeletejava training in chennai
java training in bangalore
java online training
java training in pune
java training in chennai
java training in bangalore
java training in tambaram
Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
ReplyDeleterpa training in marathahalli
rpa training in btm
rpa training in kalyan nagar
rpa training in electronic city
rpa training in chennai
rpa training in pune
rpa online training
Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
ReplyDeleteData Science training in chennai
Data science training in velachery
Data science training in tambaram
Data Science training in OMR
Data Science training in anna nagar
Data Science training in chennai
Data science training in Bangalore
Data Science training in marathahalli
It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeletePython training in usa
Python training in marathahalli
Python training in pune
Thanks you for sharing this unique useful information content with us. Really awesome work. keep on blogging
ReplyDeleteDevops Training in pune
Devops Training in Chennai
Devops training in sholinganallur
Devops training in velachery
Devops training in annanagar
Devops training in tambaram
Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
ReplyDeleteBest Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies
Fantastic blog!! with loads and loads of latest info.Thanks for sharing.
ReplyDeleteSelenium Training in Chennai
software testing selenium training
ios developer course in chennai
French Classes in Chennai
java training center in chennai
best java training institute in chennai with placement
Core Java Training
It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.
ReplyDeleteMost of ideas can be nice content.The people to give them a good shake to get your point and across the command.
data science online training
python online training
uipath online training
data science with python online training
rpa online training
Thank you for benefiting from time to focus on this kind of, I feel firmly about it and also really like comprehending far more with this particular subject matter. In case doable, when you get know-how, is it possible to thoughts modernizing your site together with far more details? It’s extremely useful to me.
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training
I have gone through your post and I found it very helpfull. Looking forward to see more post from you.
ReplyDeleteDevOps Training | Certification in Chennai | DevOps Training | Certification in anna nagar | DevOps Training | Certification in omr | DevOps Training | Certification in porur | DevOps Training | Certification in tambaram | DevOps Training | Certification in velachery
Useful and informative article.Thank you.Java training in Chennai
ReplyDeleteJava training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Online Training
data science training in chennai
ReplyDeleteccna training in chennai
iot training in chennai
cyber security training in chennai
ethical hacking training in chennai
Grab the Digital Marketing Training in Chennai from Infycle Technologies, the best software training institute, and Placement center in Chennai which is providing professional software courses such as Data Science, Artificial Intelligence, Cyber Security, Big Data, Java, Hadoop, Selenium, Android, and iOS Development, DevOps, Oracle, etc with 100% hands-on practical training. Dial 7502633633 to get more info and a free demo and to grab the certification for having a peak rise in your career.
ReplyDelete