Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
42 views

Oracle Netbeans Connectivity

This document discusses connecting to an Oracle database from Java code using NetBeans and querying a table. It loads the Oracle driver, establishes a connection to a database on localhost, creates a Statement object, executes a SQL query on the employee table to select the first name and SSN where the last name is "tank", and prints out the results.

Uploaded by

prasath_676303
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Oracle Netbeans Connectivity

This document discusses connecting to an Oracle database from Java code using NetBeans and querying a table. It loads the Oracle driver, establishes a connection to a database on localhost, creates a Statement object, executes a SQL query on the employee table to select the first name and SSN where the last name is "tank", and prints out the results.

Uploaded by

prasath_676303
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

http://stackoverflow.com/questions/9816412/oracle-11g-connectivity-with-javain-netbeans-7-1 Class.forName("oracle.jdbc.OracleDriver"); System.out.println("DRIVER LOADED!"); Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "acpsa") ; System.out.println("CONNECTION ESTABLISHED!

");

Now I want to access a table employee(fname,lname,ssn), retrieving all records and displaying them.

Statement stmt; stmt=(Statement)conn.createStatement(); String qq = "select fname,ssn from employee where lname='tank'"; ResultSet rs = (ResultSet)stmt.executeQuery(qq); while(rs.next()){ System.out.println(rs.getString("fname") + "\t" + rs.getString("ssn")); }

You might also like