Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet jsp with database oracle
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


pathan jilani
jsp with database oracle
1 Answer(s)      3 years and 11 months ago
Posted in : JSP-Servlet


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" %>


Advertisement
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>


Related Tutorials/Questions & Answers:
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
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
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 connection jsp to oracle database connections in netbeans ide
how to connection jsp to oracle database connections in netbeans ide  how to connect jsp to oracle database connections in netbeans ide?pls provide screenshots if possible
how to connection jsp to oracle database connections in netbeans ide
how to connection jsp to oracle database connections in netbeans ide  how to connect jsp to oracle database connections in netbeans ide?pls provide screenshots if possible
how to display or retrive an image in jsp whose path is stored in oracle database
how to display or retrive an image in jsp whose path is stored in oracle database  how to display or retrive an image in jsp whose path is stored in oracle database and the image is stored in my pictures folder
storing csv into oracle database
storing csv into oracle database  i want jsp code for storing csv file into oracle database
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
how to read data from excel file through browse and insert into oracle database using jsp or oracle???  sir.. i have number of excel sheets which... be inserted into oracle database.. please help me sir...   hi friend
how to generate reports from oracle database using jsp and ajax code
how to generate reports from oracle database using jsp and ajax code  Hai masters i am new to this Java world. my team leader ask me to generate sales report data from oracle database to jsp page please any one know how to do
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data..
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data.... If I use it also, unable to connect to backend oracle database. Let me... for the connection to the database is specified in the Web-inf >> config
How to Upload a file directly to Oracle database using JSP or Servlets?
How to Upload a file directly to Oracle database using JSP or Servlets?  Hi I want to upload a file(csv or excel) to Oracle 10g Database using JSP...;Upload File to Oracle Database</h2> <form id="form1" enctype
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
File insertion into oracle database
File insertion into oracle database  How to Read and Insert a file (any format) into a Oracle database
error in uploading image from jsp to oracle 10g database
error in uploading image from jsp to oracle 10g database  ... try to insert into the image into the database i got the above error please advice how to get rid of error   JSP upload image in Mysql database
Spring and Oracle Database
Spring and Oracle Database  I need example for Batch update process using oracle database and spring framework with full explanation
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
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
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
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink  I want to insert images into oracle database.I want to retrieve images using jsp and I want to display on the browser.The
java and oracle - JSP-Servlet
to upload the resume of the employee and store it into database and retrieve the same... data types in oracle database. And I need to write the code in servlets and jsp
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
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
jsp connection with oracle.
jsp connection with oracle.  I want to connect with jsp to oracle,,,plz send me the codes
jsp connection with oracle.
jsp connection with oracle.  I want to connect with jsp to oracle,,,plz send me the codes
android connection to database oracle 10g
android connection to database oracle 10g  Hello, How i can connect my android application to my oracle 10g database
Connecting Oracle database with struts - Struts
Connecting Oracle database with struts  Can anyone please provide me some solutions on Connection between Oracle database and struts
Oracle Database error - JDBC
Oracle Database error   String query11 = "SELECT product_code, product_quantity, price FROM o"+orderid; ResultSet rs11 = stmt.executeQuery(query11); while(rs11.next()){ product_code[j
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
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end
How to get the data from the database (Oracle) in console or in ie using servlet or jsp as Front end  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have created one jsp
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
Advertisements
 

 

 

DMCA.com