jsp page connectivity with oracle

jsp page connectivity with oracle

View Answers

September 3, 2009 at 2:50 PM

Hi Friend,

1)Import the packages:

<%@ page import="java.sql.*"%>

2)Load the oracle driver:

Class.forName("oracle.jdbc.driver.OracleDriver");

3) Connect to database:

a) If you are using oracle oci driver,you have to use:
Connection connection= DriverManager.getConnection("jdbc:oracle:oci8:
@oracle.world", "root", "root");

where oracle.world is the TNS NAMES entry and root is the username and password.

b) If you are using oracle thin driver,you have to use:

Connection connection= DriverManager.getConnection ("jdbc:oracle:thin:@localhost:3306:roseindia",
"root", "root");

where localhost is the host,3306 is the port, roseindia is the database and root is the username and password.

4)Querying the database:

a)create statement:

Statement st = connection.createStatement();

b)write query and execute the query:

ResultSet rs = st.executeQuery("SELECT * from data");

5) Close the statement,resultset and connection:

rs.close();
st.close();
connection.close();

Example:
<%@ page import="java.sql.*"%>
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection("jdbc:oracle:thin: @localhost:3306:Oracle", "rose", "rose");
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery("Select * from data");
while(rs.next(){
String name=rs.getString("name");
String add=rs.getString("address");
out.println(name+" "+add);
}
rs.slose();
st.close();
connection.close();
}
catch (Exception ex) {}
%>

Thanks









Related Tutorials/Questions & Answers:
jsp page connectivity with oracle - SQL
jsp page connectivity with oracle  I am unable to database connectivity jsp with oracle. Please send the code for solving problem. thanks  Hi Friend, 1)Import the packages: 2)Load the oracle driver
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
Advertisements
oracle connectivity
oracle connectivity  con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","hr","hr"); i have error on above line when i tried...=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","hr","hr
online database connectivity issue from JSP page .
online database connectivity issue from JSP page .  Hi; Everything working fine in localhost , but facing a simple problem in connectivity... following code in online connectivity ---- Class.forName
online database connectivity issue from JSP page .
online database connectivity issue from JSP page .  Hi; Everything working fine in localhost , but facing a simple problem in connectivity... in online connectivity ---- Class.forName
online database connectivity issue from JSP page .
online database connectivity issue from JSP page .  Hi; Everything working fine in localhost , but facing a simple problem in connectivity... in online connectivity ---- Class.forName
oracle connectivity problem with netbeans
oracle connectivity problem with netbeans  sir I am using oracle.... for this after adding new driver(ojdbc6.jar) in services tab I got connectivity with oracle... of simple connectivity with oracle in this I am giving driver details
jdbc oracle connectivity problem
jdbc oracle connectivity problem  Hi All, I am trying to connect my swing application to oracle DB . but class.forname is giving error. Please suggest me if there is some different way to connect swing application to oracle
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
servelet connectivity with oracle using procedure
servelet connectivity with oracle using procedure   kindly elaborate how servlet code connect to oracle br using procedure
how to load a table of data from oracle, to a jsp page using hashmap.
how to load a table of data from oracle, to a jsp page using hashmap.  I have a jsp page which ask for project ID,team name,member name according to this data i have to retrieve their details from the database(oracle). I have
Database Connectivity Withe Oracle
Database Connectivity Withe Oracle  Develop a program to perform the database driven operation like insert, Delete, Update and select. To perform the above operations create one table named Employee. Field Name Field Type EmpId
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
Java vs Oracle Connectivity - JDBC
Java vs Oracle Connectivity  Write a java program to establish connection with oracle database?  Hi Friend, Use Oracle with Java... are using oracle oci driver,you have to use: Connection conn
how to solve this problem for oracle connectivity
how to solve this problem for oracle connectivity  Exception in thread "main" java.sql.SQLException: Io exception: The Network Adap ter could not establish the connection
jdbc connectivity through jsp
jdbc connectivity through jsp  my code: <%@ page language="java... org.apache.jasper.JasperException: An exception occurred processing JSP page /mypage.jsp...://www.w3.org/TR/html4/loose.dtd"> <%@ page import="java.sql.*"%> <%@ page
OCI Connectivity For Oracle Plz Solve This Error
OCI Connectivity For Oracle Plz Solve This Error  import java.io.*; import java.sql.*; import java.lang.*; import oracle.jdbc.OracleDriver; public..."); con=DriverManager.getConnection("jdbc:oracle:thin
OCI Connectivity For Oracle Plz Solve This Error
OCI Connectivity For Oracle Plz Solve This Error  import java.io.*; import java.sql.*; import java.lang.*; import oracle.jdbc.OracleDriver; public..."); con=DriverManager.getConnection("jdbc:oracle:thin
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
java and oracle - JSP-Servlet
... data types in oracle database. And I need to write the code in servlets and jsp
jsp-oracle validation - JDBC
jsp-oracle validation  Dear friends, my validation not takes place.... --------------------------------------- logoutaction.jsp --------------------------------------- oracle 10g...; } login page User Name
connectivity - JSP-Servlet
to connect that datas to Jsp Program.kindly help me
Database connectivity with jsp code - JSP-Servlet
Database connectivity with jsp code  I have written a program in java having connectivity with online_exam. Its working properly. Connection has been... is there with jsp code.Its giving the exceptions I have posted u before. I dont know
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... this problem <%@ page import ="java.sql.*" %> <%@ page import ="java.util.
code to establish jdbc database connectivity in jsp
code to establish jdbc database connectivity in jsp  Dear sir, i'm in need of code and procedure to establish jdbc connectivity in jsp
code to establish jdbc database connectivity in jsp
code to establish jdbc database connectivity in jsp  Dear sir, i'm in need of code and procedure to establish jdbc connectivity in jsp
java and oracle - JSP-Servlet
Mysql for this purpose. Try the following code: Pagination of JSP page Roll No Name Marks Grade  
database connectivity using jsp code
database connectivity using jsp code  i have two tables employee...),'bbbb','bbbb'); so this syntax is possible to use in jsp code based on employee id ename and designation are displayed how it is possible in jsp employee
Jdbc connectivity in java to oracle for retrieving data between two dates
Jdbc connectivity in java to oracle for retrieving data between two dates  Dear Sir, I Need a program in which i want to retrieve the data b/w two... am using the oracle. please help. thankyou sir
how to save images in oracle using JSP
how to save images in oracle using JSP  how to insert images in oracle using jsp
how to save images in oracle using JSP
how to save images in oracle using JSP  how to insert images in oracle using jsp
jsp sql server 2005 connectivity
jsp sql server 2005 connectivity  your jsp mysql tutorial is very help full.Please tell me how to connect jsp with SQL server 2005
Pagination in jsp using oracle and not sql
Pagination in jsp using oracle and not sql  I need the code for pagination in jsp using oracle. I already tried it with rownum between instead of limit in sql.Please do forward me the code as soon as possible.   JSP
code for user registration page and login page of emails using jsp
code for user registration page and login page of emails using jsp  hiiiiiii please send me the code for user registration page and login page of email using jsp and servlets and also code for database connectivity to oracle
retrive data from oracle to jsp
retrive data from oracle to jsp  i am a beginer in jsp so please help me out..... in file create project i am entering proj details such as id name cost and manager name and storing it in the data base. in search proj fiel
error at the oracle programm with jsp - JSP-Servlet
error at the oracle programm with jsp  an error occured at myodbc:jdbc:missig comma
Retrieve database from the table dynamically in jsp from oracle using servlet
Retrieve database from the table dynamically in jsp from oracle using servlet  Sir, I have created a table in oracle using eclipse, and added few... using java servlet from the database in the jsp page
jsp page - JSP-Servlet
jsp page  what are elemets and template data in jsp page??  Hi Friend, Template Data is a parameterized content that allows the JSP document to generate a response stream of characters. JSP Elements provides
how to create a bar chart in jsp by fetching value from oracle databse?
how to create a bar chart in jsp by fetching value from oracle databse?  i want to show the population of various states in a bar chart in my jsp page by fetching the data from my oracle table. i am using my eclipse as my IDE
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
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
how to set time in jsp page
how to set time in jsp page   I need code for set the time in jsp code .iam using struts frame work back end oracle 10g ide is eclipse 6.0
jsp page
jsp page  <%@page contentType="text/html" pageEncoding="UTF-8"%>...;%@page import="java.sql.Statement"%> <%@page import="java.sql.DriverManager"%> <%@page import="java.sql.Connection"%> <%@page import
Java servlet sql connectivity error - JSP-Servlet
Java servlet sql connectivity error  Hi, I have been trying to connect to sql database via the servlet program in java.I have not been successful so far. However when i try to connect to sql through a normal java program
JSP Tutorials - Page 3
JSP Tutorials - Page 3
jsp page
jsp page  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Ads