jsp with database oracle
hai i am doing one program in jsp i want to check the jsp life cycle methods so wrote one program, in which i write jspInit() method and jspDestroy() methods. but i am getting error
i crate a table with the name employee
i am sending sample code to u. plz help me to fix this problem
<%@ page import ="java.sql.*" %>
<%@ page import ="java.util.*" %>
<%!
Connection con;
PreparedStatement ps;
public void jspInit()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:online","system","manager");
ps=con.prepareStatement("insert into employees values(?,?,?)");
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void jspDestroy()
{
try
{
ps.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
%>
<%
int eno = Integer.parseInt(request.getParameter("t1"));
String name=request.getParameter("t2");
float sal = Float.parseFloat(request.getParameter("t3"));
ps.setInt(1,eno);
ps.setString(2,name);
ps.setFloat(3,sal);
ps.executeUpdate();
%>
<%@ include file ="emp.html" %>
View Answers
February 9, 2011 at 1:38 PM
JSP with access database
To set up the DSN connection, follow these steps:
1)Go to the start<<Control Panel<<Administrative Tools<< data sources.
2)Click Add button and select the driver Microsoft Access Driver(*.mdb).
3)After selecting the driver, click finish button.
4)Then give Data Source Name and click ok button.
5)Your DSN will get created.
6) Restart your server and run your jsp code.
JSP code
<%@page import="java.sql.*"%>
<table border=1>
<tr><th>Name</th><th>Address</th></tr>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:student");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from data");
while(rs.next()){
%>
<tr><td><%=rs.getString("name")%></td><td><%=rs.getString("address")%></td></tr>
<%
}
rs.close();
st.close();
con.close();
}
catch(Exception e){}
%>
</table>
Ads
Related Tutorials/Questions & Answers:
oracle database backup using jsp
oracle database backup using
jsp I want to take the backup of
oracle database.I want to write the code in
jsp ,so that when the page is loaded a backup of the
database is stored in one of my local drives.Is it possible to do
jsp with database oracle
jsp with
database oracle hai i am doing one program in
jsp i want to check the
jsp life cycle methods so wrote one program, in which i write jspInit() method and jspDestroy() methods. but i am getting error
i crate a table
Advertisements
fetch record from oracle database using jsp-servlet?
fetch record from
oracle database using
jsp-servlet? how can i fetch data from
oracle database by using
jsp-servlet. i'm using eclipse, tomcat server and
oracle database and creating
jsp pages and also using servlet
How to get data from Oracle database using JSP
problem in
jsp in the sense to get data from the
database like
oracle . I have... data from the
database like
oracle), I have created one
jsp program like... in the sense to get data from the
database like
oracle . I have created one
jsp
JSP-Oracle connectivity
JSP-
Oracle connectivity I have created a "dynamic web project" mainly with
jsp files in eclipse and now, want to connect with
oracle 10g, so how can I proceed for the
database connection
retrieving from oracle database using jsp combo box
retrieving from
oracle database using
jsp combo box hi this is my... name of the server has to display in the process name field from the
oracle database please help on this i need code using servlets please help me .
<
write excel file into the oracle database
write excel file into the
oracle database dear sir,
i need the
jsp code that reads the excel file and stores it into the
oracle database table..and also i need the code to connect
oracle database?
thank u in advance
Spring and Oracle Database
Spring and
Oracle Database I need example for Batch update process using
oracle database and spring framework with full explanation
java with Oracle Database
java with
Oracle Database Hello
I have been encountering a problem regarding creating a table with Oracle.When i am creating new table in the
Database using
Oracle , it is giving error saying an errror occured incursive sql
Oracle Database connectivity probem
Oracle Database connectivity probem hi
Below is the code of
oracle database connectivity, when i compile it, it will show the error... also set the environment variable like that .;E:\
oracle\ora81\jdbc\lib
error oracle database connection?
error
oracle database connection? hi now i am trying to connect
oracle database and also insert my data into table, but it's not working.. I created... in
oracle table. my table name is logininfoclient_sla. this is my coding
Oracle 9i database problem
Oracle 9i
database problem Hi Somebody has given the solution but i...
Oracle 9i in my laptop.and i got sql+ page ok.i have gone to control panel->odbc->in that i correctley configured DNS and TNS and tested the
Oracle
Oracle Database - Insert System Time
Oracle Database - Insert System Time Hi I want to insert only system time dynamically using a statement but not a prepared statement into
Oracle Database please suggest me any code
Java Connection to Oracle database
Java Connection to
Oracle database HI
I am ubable to connnect jdbc to
Oracle database.i had gone to control panel >>Administrative tool>>>Data source,in that forDNS name i typed
Oracle and in TNS i culdn't