Java and Oracle Application Development with NetBeans IDE - Prof. Kai Qian, Assignments of Deductive Database Systems

A step-by-step guide on how to build a java application using oracle database with netbeans ide. It covers installing the oracle driver, creating a table, and writing the java code to query the database.

Typology: Assignments

Pre 2010

Uploaded on 08/03/2009

koofers-user-er3-1
koofers-user-er3-1 🇺🇸

10 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Java and Oracle:
Before starting this tutorial, we assume you have already installed Apache Tomcat and NetBean IDE
(version 5.5). We will build our java application using NetBean IDE.
Step 1:
At the Net Bean Startup
Select File->New Project
Then Choose General->Java Application then press Next
In the new dialog box, name your project and choose a location for it. Press finish when you finish with
it.
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Java and Oracle Application Development with NetBeans IDE - Prof. Kai Qian and more Assignments Deductive Database Systems in PDF only on Docsity!

Java and Oracle: Before starting this tutorial, we assume you have already installed Apache Tomcat and NetBean IDE (version 5.5). We will build our java application using NetBean IDE. Step 1: At the Net Bean Startup Select File->New Project Then Choose General->Java Application then press Next In the new dialog box, name your project and choose a location for it. Press finish when you finish with it.

You will see a default page index.jsp and the directory structure like this:

Create a table: After creating table insert data values Insert into TestDb values (001,'John',4047390845); After creating the Database file, Right click on the Javaapplication->properties

Click on Libraries->Add Jar/folder Add the class12.jar file, to avoid the ’java.lang.ClassNotFoundException’ Step 3: Code Leaving the package line along edit the code to this: // Main.java import java.awt.; import java.awt.event.; import javax.swing.; import java.sql.; public class Main extends JFrame implements ActionListener { private JTextField t1, t2, t3;

t1 = new JTextField( 15); c.add(t1); l2 = new JLabel( "Name: "); c.add (l2); t2=new JTextField( 15 ); c.add(t2); l3 = new JLabel( "Phone: "); c.add (l3); t3=new JTextField( 15 ); c.add(t3); b1 = new JButton("Execute"); c.add(b1); // Registration of Execute button with the action listener so that // actionPerformed method will be invocated when the button is // pressed b1.addActionListener(this); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e) { System.exit(0); } }); setSize(300,160); // Enable the frame

show(); } public void actionPerformed(ActionEvent e) { // JDBC processing if (e.getSource() == b1) { int numCols; // Search for customer information whose CustomerId is given String query = "select * from TestDb " + "where name like '" + t2.getText() + "'"; // Following JDBC code are almost identical with code of last // example try{ Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); numCols = rs.getMetaData().getColumnCount(); while(rs.next()) { t1.setText(rs.getString(1)); t2.setText(rs.getString(2)); t3.setText(rs.getString(3)); } rs.close(); stmt.close(); conn.close();}