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



Home Answers Viewqa Java-Beginners How to get data from Oracle database using JSP

Have Programming Question? Ask it here!
 
 
 


Venkatasitaramayya
How to get data from Oracle database using JSP
6 Answer(s)      2 years and 10 months ago
Posted in : Java Beginners


hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have created one jsp program like this

<@ page session="false"%> 
<@ page import="java.io.*" import="java.sql."%>
<%try { PreparedStatement ps; Connectin con;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
con=DrivergetConnection("jdbc:odbc:DNSName","scott","tiger"; ps=con.prepareStatement();
ResultSet rs=ps.executeQuery("select from Table1"); if(rs.next()) { out.println(rs.getInt(1));
out.println(rs.getString(2)); 
out.println(rs.getString(3)); 
out.println(rs.getInt(4));
} } catch(Exception e) {} rs.close(); ps.close(); con.close();
%>

But now when i iam saving this program in JSP it is alright , when i opened the Tomcat and getting the necessary path then i clicked on the JSP file i,but i am not getting any thing in the internet Browser.i have given the data (Table1) in the database.so that data should come on the Browser. but not getting.So kindly the RoseIndia netizens help to solve the problem


Advertisement
View Answers

October 10, 2011 at 12:03 PM


Use the following code:

ResultSet rs=ps.executeQuery("select * from Table1");   
 while(rs.next()) {
 out.println(rs.getInt(1));
 out.println(rs.getString(2));
 out.println(rs.getString(3));
 out.println(rs.getInt(4)); 
}


October 10, 2011 at 12:29 PM


Hi my friend roseinsia netizen has given me to execute the program by while instead of if but neither while nor if statements iam not getting the solution .Exactly what i have done is that ( i have a simple problem in jsp in the sense to get data from the database like oracle), I have created one jsp program like this

*<@ page session="false"%> <@ page import="java.io." import="java.sql."%> <%try { PreparedStatement ps; Connectin con; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DrivergetConnection("jdbc:odbc:DNSName","scott","tiger"; ps=con.prepareStatement(); ResultSet rs=ps.executeQuery("select from Table1"); while(rs.next()) { out.println(rs.getInt(1)); out.println(rs.getString(2)); out.println(rs.getString(3)); out.println(rs.getInt(4)); } } catch(Exception e) {} rs.close(); ps.close(); con.close(); %>**

But now when i iam saving this program in JSP it is alright , when i opened the Tomcat and getting the necessary path then i clicked on the JSP file but i am not getting any thing in the internet Browser.i have given the data (Table1) in the database.so that data should come on the Browser. but not getting.So kindly the RoseIndia netizens help to solve the problem.



October 10, 2011 at 1:26 PM


You have used incorrect query. Actually you didn't clear which data you want to retrieve. Neither you have used * nor you have specifies particular field.So if you want to retrieve all the fields then use this code:

 ResultSet rs=ps.executeQuery("select * from Table1");   
 while(rs.next()) {
 out.println(rs.getInt(1));
 out.println(rs.getString(2));
 out.println(rs.getString(3));
 out.println(rs.getInt(4)); 
}

And if you want to retrieve the particular data then use this code:

ResultSet rs=ps.executeQuery("select * from Table1 where id=1");   
     if(rs.next()) {
     out.println(rs.getInt(1));
     out.println(rs.getString(2));
     out.println(rs.getString(3));
     out.println(rs.getInt(4)); 
    }


October 19, 2011 at 7:38 PM


hello My Netizen friend has given the answer to retrieve data from the database by using servlet or jsp program by typing the output as like this below

ReusltSet rs=statement.executeQuery("select * from Table1)
while(rs.next()) {
 out.println(rs.getInt(1));
 out.println(rs.getString(2));
 out.println(rs.getString(3));
 out.println(rs.getInt(4)); 
}

But still i am not gettin the output from the Browser. i have a simple problem in jsp in the sense to get data from the database like oracle . I have created one jsp program like this

<@ page session="false"%>
<@ page import="java.io.*" import="java.sql."%>
<%try { PreparedStatement ps;
Connectin con;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DrivergetConnection("jdbc:odbc:DNSName","scott","tiger";
ps=con.prepareStatement();
ResultSet rs=ps.executeQuery("select from Table1");
if(rs.next()) { out.println(rs.getInt(1));
out.println(rs.getString(2));
out.println(rs.getString(3));
out.println(rs.getInt(4));
} 
} c
atch(Exception e) {} rs.close();
ps.close();
con.close();
%>

But now when i iam saving this program in JSP it is alright , when i opened the Tomcat and getting the necessary path then i clicked on the JSP file i,but i am not getting any thing in the internet Browser.i have given the data (Table1) in the database.so that data should come on the Browser. but not getting.So kindly the RoseIndia netizens help to solve the problem



January 28, 2012 at 7:34 PM


<@ page session="false"%> 
<@ page import="java.io.*" import="java.sql.*"%>
 <%try { 
PreparedStatement ps=null; 
Connectin con=null; 
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:DNSName","scott","tiger"); 
ps=con.prepareStatement("select * from Table1");
 ResultSet rs=ps.executeQuery();
 while(rs.next()) 
{ 
out.println(rs.getInt(1)); 
out.println(rs.getString(2));
out.println(rs.getString(3)); 
out.println(rs.getInt(4));
 } } catch(Exception e) {} 
rs.close(); 
ps.close();
 con.close(); %>


October 3, 2012 at 6:03 PM


ResultSet rs=ps.executeQuery("**select from Table1**");

**Incorrect statement:**
select from Table1

**Correct statement:**
select * from Table1

**Write code:** 
ResultSet rs=ps.executeQuery("**select * from Table1**");

It's really work   ......


Related Tutorials/Questions & Answers:
How to get data from Oracle database using JSP
How to get data from Oracle database using JSP  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have... in the sense to get data from the database like oracle . I have created one jsp
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
Advertisements
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 get the data from the database using Servlet or JSP program
How to get the data from the database using Servlet or JSP program  ... the problem   Get data from database using servlet Retrieve data from database using JSP Get data from database using JSP
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
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  Can anybody tell me what is the problem in this code as i am not able to fetch the data from... tutorial go through the link JSP Get Data Into Dropdown list From Database   
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  //Customer Name: <select name="name"> <% try{ Class.forName...="select * from staff"; ResultSet rs=st.executeQuery(sql); while(rs.next
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
how to get data from database into dropdownlist in jsp
how to get data from database into dropdownlist in jsp  Customer Name:<select name="name"> <% try{ Class.forName...=con.createStatement(); String sql="select * from staff"; ResultSet rs
JSP Get Data From Database
JSP Get Data From Database In this section we will discuss about how to get data from database using JSP. To get data from database to a JSP page we... example which lets you understand to fetch data from database in JSP
how to get the values to dropdownlist from oracle database
how to get the values to dropdownlist from oracle database   <...("jdbc:oracle:thin:@192.168.149.95:1521:MOBIRAC1","SCOTT","SCOTT"); Statement... * from countryname"); while(rs.next()){ %> <option value="<
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I... with a and from that i need to select the required value and i should store
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 sub category based on category from database using jsp and javascript.
How to get sub category based on category from database using jsp and javascript.  How to get sub category based on category from database using jsp and javascript
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
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
how to display data from database in jsp
how to display data from database in jsp  how to display data from database in jsp
how to get data from checkboxes - JSP-Servlet
how to get data from checkboxes  hi, i got list of tables on screen by invoking webservices.when the user selects the tables by using checkboxes, i need to get only those tables to the next page where i can get list of columns
unable to get datas from oracle database
unable to get datas from oracle database  Dear Sir, I am again struck in my project.. i want to display data from oracle database but i get this error when i run the jsp file in tomcat, I post my code below.. kindly let me
How retreive data from database without using post method in jsp - JSP-Servlet
How retreive data from database without using post method in jsp  Tell me how?  Hi Friend, If you don't want to use post method then use... the selected value from the combo box and get textbox value from another page
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 the text from textarea in HTML and store it in database using javascript and jsp
How to get the text from textarea in HTML and store it in database using javascript and jsp  How to get the text from textarea in HTML and store it in database using javascript and jsp <script> function str() { <
retrive data from database using jsp in struts?
retrive data from database using jsp in struts?   *search.jsp* <... searchProduct(SearchDTO sdto) { String query="select * from product...()); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521
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 . <
retrive data from oracle to jsp
retrive data from oracle to jsp  i am a beginer in jsp so please help... cost and manager name and storing it in the data base. in search proj fiel...(); psmt= conn.prepareStatement("select * from CR_EMPLOYEE_DETAILS
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve the particular record from the database and display it in textbox using JSP. <
JSP Get Data Into Dropdown list From Database
JSP Get Data Into Dropdown list From Database In this section we will discuss... data from the database and set it into the dropdown list in JSP using MySQL.... This tutorial explains you that how to fetch data from database and set
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what... = null; // declare a resultset that uses as a table for output data from... and database name. Here machine name id localhost and database name
callable statement,stored procedure for insert data and also for update data into oracle database using jsp
callable statement,stored procedure for insert data and also for update data into oracle database using jsp  iam a fresher newbie to softparsing i... procedure for inserting data into oracle database as bind variable and same
How to retrieve data from database by using combo box value in jsp? - JSP-Servlet
How to retrieve data from database by using combo box value in jsp?  Hello friend i want use only one jsp page.. but u give 2 pages... I want...="+emp_value xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url
Select tag to fetch data from oracle database
Select tag to fetch data from oracle database  I created a select box... oracle database.Similarly when address will be selected by the user from... of a student and when regnno is selected from the drop down list by a user
How to get the most recent data from the sql database
How to get the most recent data from the sql database  Hi, just wanted to show the most recent row from the database table...in my web page. for example if i have four records in the table that was added on different different
how to get the data from database - Java Server Faces Questions
how to get the data from database  In database i have created some tables(person details) and i have one jsf page in that one search button... me the procedure how to do this application.Database is mysql.  Hi
how to insert data into database using jsp & retrive
how to insert data into database using jsp & retrive  Hello, I have created 1 html page which contain username, password & submit button. in my oracle10G database already contain table name admin which has name, password
How to Get The Data from Excel sheet into out jsp page???
How to Get The Data from Excel sheet into out jsp page???  How to Get The Data from excel sheet to out jsp page in webApp
using ajax i want to insert data into oracle database
using ajax i want to insert data into oracle database  i would like to insert/update/select/delete from jsp to oracle database using ajax? please send a code for this iam using oracl database thank you
Read data from excel file and update database using jsp
Read data from excel file and update database using jsp  read data from excel file and update database using jsp Hi, I am using a MySQL database... upload excel file and update database using JSP ? Thanks in Advance
how to display data from jsp file into database
how to display data from jsp file into database  this is a jsp file...+",'"+email+"')"); out.println("Data is successfully inserted into database...(); in the below example. the error is "cannot convert from java.sql.Statement
how to get data from list to map with out using a loop?
how to get data from list to map with out using a loop?  List list...("15"); how to get this data into map with out using a loop. i want this data like this--map.put(name,id); Is it possible to do without using loop
How save,get picture from database in my jsp page?
How save,get picture from database in my jsp page?  How i save picture in db after browsing it,and also how i get it on my other jsp page
how i conditional access the data from database using combo box. - JSP-Servlet
how i conditional access the data from database using combo box.   i... appears named Subject values Arts, Commerce, Science. how i conditional access the data from database when i select class 11 0r 12. Here is JSP file
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
How Can I get ArrayList of Data from jsp with ajax request
How Can I get ArrayList of Data from jsp with ajax request  Hi, I retereved 5 Employee Record of Data from Struts Action class to jsp with ajax response. But I don't how how can reterve this dynamic 5 employee records
how to get the data from database&how to display the database data in jsf - Java Server Faces Questions
how to get the data from database&how to display the database data in jsf  Hi, 1.how to get the data from database. 2.how to display the database...; Hi friend, To Solve the Problem get the data from database
how to get data using dropdownlist, textbox and search button in jsp
how to get data using dropdownlist, textbox and search button in jsp  Hi, I want to display data using jsp,javascript and mysql. My Q. is If i select an entry suppose 'title' from dropdownlist and give a title name 'partial dif
how to retrieve data from database
how to retrieve data from database  unable to retrieve data from database using mySQL by using jsp sessions and beans for editing
retrieve related data from database using jsp and mysql
retrieve related data from database using jsp and mysql  Hi sir, please give some example of jsp code for retrieving mysql database values in multiple dropdown list. if we change a value in a dropdown its related value must
how to add data dynamically from database into a dropdown list in a jsp
how to add data dynamically from database into a dropdown list in a jsp  hi friends i am doing a project in jsp and oracle as my database.In my... get dynamically from the database and whenever a new person has registered his
How to Retrieve Data from the database and write into excel file using Java
How to Retrieve Data from the database and write into excel file using Java  Hi, I am trying to develop an small application where i trying to retrieve Data from the database and store the details in excel file. Please can
how to save images in oracle using JSP
how to save images in oracle using JSP  how to insert images in oracle using jsp
Advertisements
 

 

 

DMCA.com