JDBC APPLICATION FOR EMPLOYEE DATA SOURCE
AIM:
To write a program to manipulate the employee database.
PROCEDURE:
1.CODE WINDOW:
Step 1: Start IBM Websphere Application by selecting Start àAll Programs àIBM
webSphere Studio àApplication Developer 5.0.
Step 2: A dialog box appear in that enter the directory for that session and click OK.
Step 3: A window appear in that select FileàNewàProject.
Step 4: In the new project dialog box select Java from the left pane and Java project from
the right Pane and then click next button.
Step 5: Enter a project name and click finish .
Step 6: Click on the new class Icon.
Step 7:In the new dialog box and give a name to the class as student and select the modifier
as public and super class as import java.sql.*.
Step 8: Select the type of stub as public static void main(String args[]) and click ok
Step 9:A skeleton of the java program is appear in the window .Type the program in that window.
2.JDBC CONNECTIVITY:
Step 1:Start .
Step 2: Declare the necessary variables.
Step 3: Register the driver using the following statement.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Step 4:Create a connection using the following statement.
Connection con=DriverManager.getConnection("jdbc:odbc:dsnname",”userid”,”password”);
Step 5:STATIC SQL
The code for execute the static query is given below
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery( SQL);
Step 6:DYNAMIC SQL
The code for execute dynamic sql query is given below
PreparedStatement ps=con.prepareStatement(SQL);
count=ps.executeUpdate() ;
0 comments:
Post a Comment