Share on Google+Share on Google+

raghulan
unable to get datas from oracle database
0 Answer(s)      4 years and 6 months ago
Posted in : JDBC

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 know what i am wrong!! kindly help me in this.

out.jsp

    <%@ page session="false"%> 
    <%@ page import="java.io.*" import="java.sql.*"%>
     <%try { 
    Connection con=null; 

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

    Connection 
    con=DriverManager.getConnection("jdbc:oracle:thin:@//172.25.50.247:1521/knits", "ADMIN", "ADMIN");

    ps=con.prepareStatement("select * from departments");
     ResultSet rs= ps.executeQuery();
     while(rs.next()) 
    { 
    out.println(rs.getInt(name)); 
    out.println(rs.getString(id));
     } } catch(Exception e) {} 
    rs.close(); 
    ps.close();
    con.close(); %>

Error from apache tomcat type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 9 in the jsp file: /jsp/test/form.jsp
Duplicate local variable con
6: Class.forName("oracle.jdbc.driver.OracleDriver");
7: 
8: Connection 
9: con=DriverManager.getConnection("jdbc:oracle:thin:@//172.25.50.247:1521/knits", "ADMIN", "ADMIN");
10: 
11: ps=con.prepareStatement("select * from departments");
12:  ResultSet rs= ps.executeQuery();

An error occurred at line: 11 in the jsp file: /jsp/test/form.jsp
ps cannot be resolved to a variable
8: Connection 
9: con=DriverManager.getConnection("jdbc:oracle:thin:@//172.25.50.247:1521/knits", "ADMIN", "ADMIN");
10: 
11: ps=con.prepareStatement("select * from departments");
12:  ResultSet rs= ps.executeQuery();
13:  while(rs.next()) 
14: { 

An error occurred at line: 12 in the jsp file: /jsp/test/form.jsp
ps cannot be resolved
9: con=DriverManager.getConnection("jdbc:oracle:thin:@//172.25.50.247:1521/knits", "ADMIN", "ADMIN");
10: 
11: ps=con.prepareStatement("select * from departments");
12:  ResultSet rs= ps.executeQuery();
13:  while(rs.next()) 
14: { 
15: out.println(rs.getInt(name)); 

An error occurred at line: 15 in the jsp file: /jsp/test/form.jsp
name cannot be resolved to a variable
12:  ResultSet rs= ps.executeQuery();
13:  while(rs.next()) 
14: { 
15: out.println(rs.getInt(name)); 
16: out.println(rs.getString(id));
17:  } } catch(Exception e) {} 
18: rs.close(); 

An error occurred at line: 16 in the jsp file: /jsp/test/form.jsp
id cannot be resolved to a variable
13:  while(rs.next()) 
14: { 
15: out.println(rs.getInt(name)); 
16: out.println(rs.getString(id));
17:  } } catch(Exception e) {} 
18: rs.close(); 
19: ps.close();

An error occurred at line: 18 in the jsp file: /jsp/test/form.jsp
rs cannot be resolved
15: out.println(rs.getInt(name)); 
16: out.println(rs.getString(id));
17:  } } catch(Exception e) {} 
18: rs.close(); 
19: ps.close();
20: con.close(); %>

An error occurred at line: 19 in the jsp file: /jsp/test/form.jsp
ps cannot be resolved
16: out.println(rs.getString(id));
17:  } } catch(Exception e) {} 
18: rs.close(); 
19: ps.close();
20: con.close(); %>

An error occurred at line: 20 in the jsp file: /jsp/test/form.jsp
con cannot be resolved
17:  } } catch(Exception e) {} 
18: rs.close(); 
19: ps.close();
20: con.close(); %>

Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.

Ads

View Answers









Related Tutorials/Questions & Answers:
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...("jdbc:oracle:thin:@//172.25.50.247:1521/knits", "ADMIN", "ADMIN"); ps
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="<
Advertisements
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... from oracle sql*plus as rajalakshmi and password by granting privilege from scott
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
java script unable to connect to oracle database and insert data
java script unable to connect to oracle database and insert data  ... is to insert data from jsp to oracle database 8, so i create a table in oracle... to run the jsp file from tomcat i get this error.. let me know what i am doing
Unable to get data from class - Development process
Unable to get data from class  I get this code from the internet which read from comm port of the computer & modify is as below:- package COM... the getWeight() function from this ComControl class when i click the Jbutton2
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... in the sense to get data from the database like oracle . I have created one jsp...","tiger"); ResultSet rs=ps.executeQuery("select from Table1"); if(rs.next
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
store & retrive the image from oracle database
store & retrive the image from oracle database  how can i store the image path in tha database & fetch that image from oracle database
unable to get value returned from javascript variable in page
unable to get value returned from javascript variable in page  Hi, I have 3 pages....i wrote a js function to get the value of radio button from one jsp page..what i want is to store the value returned from the js function
get information from database
get information from database  get information from database   Please visit the following links: http://www.roseindia.net/sql/mysql-table/mysql-php-select.shtml http://www.roseindia.net/sql/mysql-example/select
Dropdown code to retrieve result from oracle database
Dropdown code to retrieve result from oracle database  Hi Friends, I... retrieve the result from Oracle database.We have procedures created already.Just... that will retrieve values from the database into dropdown. As the user choose any option
how to generate reports from oracle database using jsp and ajax code
how to generate reports from oracle database using jsp and ajax code  ... sales report data from oracle database to jsp page please any one know how to do... member Java programmer unable to do this task..so its burden on me to finish
unable to validate username and password from ms acess database
unable to validate username and password from ms acess database  this code is not working! please help me to find error. thanks. <%@ page... * from table1 where userid='"+user+"' and pwd='"+pwd+"'"); int i=0
unable to validate username and password from ms acess database
unable to validate username and password from ms acess database  this code is not working! please help me to find error. thanks. <%@ page... * from table1 where userid='"+user+"' and pwd='"+pwd+"'"); int i=0
unable to validate username and password from ms acess database
unable to validate username and password from ms acess database  //this code is not working! please help me to find error. thanks. <%@ page... * from table1 where userid='"+user+"' and pwd='"+pwd+"'"); int i=0
unable to validate username and password from ms acess database
unable to validate username and password from ms acess database  //this code is not working! please help me to find error. thanks. <%@ page... * from table1 where userid='"+user+"' and pwd='"+pwd+"'"); int i=0
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
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
get values from Excel to database
get values from Excel to database   hi i want to insert values from Excel file into database.Whatever field and contents are there in excel file that should go to database which exists. am using SQL Server management studio
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
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... button. 4)Then give Data Source Name and click ok button. 5)Your DSN will get
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... i was using this code.... try { Driver d=(Driver)Class.forName
unable to insert data into database
unable to insert data into database    hello.i have a problem... the eid based on ename and the other is inserting data into database based... = Database.getConnection(); ps1=con.prepareStatement("select eid from employee
unable to insert data into database
unable to insert data into database    hello.i have a problem... the eid based on ename and the other is inserting data into database based... = Database.getConnection(); ps1=con.prepareStatement("select eid from employee
unable to insert data into database
unable to insert data into database    hello.i have a problem... the eid based on ename and the other is inserting data into database based... = Database.getConnection(); ps1=con.prepareStatement("select eid from employee
unable to insert data into database
unable to insert data into database    hello.i have a problem... the eid based on ename and the other is inserting data into database based... = Database.getConnection(); ps1=con.prepareStatement("select eid from employee
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... be inserted into oracle database.. please help me sir...   hi friend..., in these examples MySQL is used as database system if you want to use the Oracle
Unable to store the image into database
Unable to store the image into database  Hello, I have created below program and program is throwing FileNotFound exception when I pressed the submit...); }   Hi, Please check the thread How to Insert image into database
Unable the get SubFolder Direcotry in Java?:-
Unable the get SubFolder Direcotry in Java?:-   Unable the get SubFolder Direcotry in Java?:- try { String st1 = "C:\TestFolder; // Main Folder URL File folder = new File(st1); File[] listOfFiles = folder.listFiles(); for (File
Tutorials   
Java Spring Hibernate Struts Training how to retrieve text and images from mysql database and show on html page using jsp servlet How to install Neo4j on Ubuntu 15.10? please help me in these prog MYSQL - mysql copy table to another table example by creating new table solution for mapping hibernate and pojos from net beans through database Connect GWT application with Oracle inventory System of Medical Store inventory System of Medical Store inventory System of Medical Store inventory System of Medical Store This code have created jTable that connected with a database.every cell of last column have a button.But this button doesn't work properly.Where is the error java program Java Database Program jdbc Database connection class in a live project ..?? What is JDBC architecture? Unable to Create DSN for excel to ms access importing data and edit that data Database Scrolling Buttons how to use foreign key in java How to delete content of a log file from linux terminal? JSP-Oracle connectivity Student Management System Java code for Saving Marathi (Indian local language ) in Mysql and retrieving the same crud operations with foreign key constraint. I really need help with this assignment question Please help me out Please Backup Failed Mysqldump Got Errno 28 On Write Upgrade MySQL 5.1 to 5.5 in cpanel mysqldump all databases com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jpa.sequence' doesn't exist persistence xml class element persistence.xml for MySQL MySQL JDBC Driver pom dependency code Blob column jdk6 and oracle 8i connexion oracle 8i et jdk6 java [ cannot retrive date from sql ] why?? Order Entry System How to threow timeout exception when DB is not responding How to threow timeout exception when DB is not responding This is the employee form to add data to mysql database but I got error of NullPointerException, Is this write code please give me feedback as soon as possible make a method which takes user name & pwd as parameter & validate them against the database. If the corresponding user exist return true otherwise false. prabhakar validating credentials and displaying error message in login .jsp if not valid JDBC jdbc jdbc code register servlet vibhu connectiondetails from vibhu

Ads

 
Advertisement null

Ads