Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data..

Ads

 
 

Share on Google+Share on Google+

sushma
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data..
0 Answer(s)      5 years and 4 months ago
Posted in : JSP-Servlet

I have a class file AbstractDataAccessObject with the below code.

package com.dts.core.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

import com.dts.core.util.LoggerManager;

public class AbstractDataAccessObject
{
    public Connection mCon;
    private static Properties mProps;

    /**
     * @return the props
     */
    public Properties getProperties()
    {
        return mProps;
    }

    /**
     * @param props
     *            application properties object
     */
    public void setProperties(Properties aProps)
    {
        mProps = aProps;
    }

    public Connection getConnection()
    {
        try
        {
            Properties aProps = getProperties();
            System.out.println(aProps.getProperty("driver"));
            Class.forName(aProps.getProperty("driver"));
            mCon = DriverManager.getConnection(aProps.getProperty("url"), aProps.getProperty("duser"), aProps.getProperty("dpass"));
            System.out.println(mCon);
        }
        catch (ClassNotFoundException cnfe)
        {
            LoggerManager.writeLogWarning(cnfe);
        }
        catch (SQLException se)
        {
            LoggerManager.writeLogWarning(se);
        }
        return mCon;
    }

/*  public Connection getConnection(String cp)
    {
        try
        {
            Properties aProps = getProperties();
            Class.forName( aProps.getProperty("driver") );

            String JNDI = aProps.getProperty("JNDI_NAME");

            try
            {
                InitialContext ictx = new InitialContext();
                DataSource ds = (DataSource) ictx.lookup(JNDI);
                mCon = ds.getConnection();
            }
            catch (NamingException ne)
            {
                LoggerManager.writeLogWarning(ne);
            }
        }
        catch (ClassNotFoundException cnfe)
        {
            LoggerManager.writeLogWarning(cnfe);
        }
        catch (SQLException se)
        {
            LoggerManager.writeLogWarning(se);
        }
        return mCon;
    }*/

    public int getSequenceID(String tableName, String pkid)
    {
        int id = 0;
        try
        {
            mCon = getConnection();
            Statement st = mCon.createStatement();
            ResultSet rs = st.executeQuery("select max("+pkid+") from "+tableName); 
            if(rs.next())
                id=rs.getInt(1);
            id++;
        }
        catch(SQLException se)
        {
            LoggerManager.writeLogWarning(se);
        }
        catch(Exception e)
        {
            LoggerManager.writeLogWarning(e);
        }
        finally
        {
            try
            {
                mCon.close();
            }
            catch(SQLException se)
            {
                LoggerManager.writeLogWarning(se);  
            }
            catch(Exception e)
            {
                LoggerManager.writeLogWarning(e);
            }
        }
        return id;
    }
}

The data for the connection to the database is specified in the Web-inf >> config >>system.properties.

The code is as follows

# Sample ResourceBundle properties file

JNDI_NAME=java:com/env/Oracle/jndi
db.login=   
db.password= 
driver=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@192.168.100.20:1521:server
duser=ware
dpass=ware
logfile=E:/log/warehouse_log.txt
dbname=oracle

Let me know what is the duser and dpass.. ? I have created a new user from oracle sql*plus as rajalakshmi and password by granting privilege from scott and tiger. should I use the duser and dpass as rajalakshmi and password for duser and dpass.. or scott and tiger.

But nothing of the duser and dpass works.

If I use it also, unable to connect to backend oracle database.

Let me know what is db.username and db.password? should I leave it blank ?

Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
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...) { LoggerManager.writeLogWarning(e); } } return id; } } The data
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... jsp coding in rose india for sql and i changed the drivers for oracle.. when i try
Advertisements
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... Driver Manager] Data source name not fou nd and no default driver specified
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...: [Microsoft][ODBC Driver Manager] Data source name not fou nd and no default driver
unable to connect to server - JSP-Servlet
unable to connect to server  thank you for the program code for inserting and reteriving the image but i am unable to deploy these two programs..., create a web application folder inside the webapps folder and put the jsp file
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
unable to insert data into database
unable to insert data into database    hello.i have a problem in inserting data into database.i have used two prepared statement.one for retrieving the eid based on ename and the other is inserting data into database based
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... org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred
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
Unable to store the image into database
Unable to store the image into database  Hello, I have created below... button. The problem is coming due to JSP page is not able to find complete path of image. I have debug the JSP program and found that HTML form pass only image
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp   data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp with script of data base plz help me
Unable to execute JSP page
Unable to execute JSP page  I have written one jsp file. It contains html tags and jsp directives. I have saved the file with the extension .jsp. The tomcat server is already running onto my machine. I have saved the jsp file
Insert or retrieve image into oracle 10g by using java
Insert or retrieve image into oracle 10g by using java   How can i insert or retrieve image into oracle10g using java plz i need it urgently,need guidance to do this plz
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
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
Unable to compile class for JSP - WebSevices
Unable to compile class for JSP  org.apache.jasper.JasperException: Unable to compile class for JSP When I am trying to access a java file kept under src folder under a package from a jsp page placed under web directory, I am
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
Unable to upload a file to mysql database using struts1
Unable to upload a file to mysql database using struts1  Hi, Below are my classes 1.upload.jsp <%@ taglib uri="/tags/struts-html" prefix="html...="multipart/form-data"> Select a File :<html:file property="file"/> <
Unable to run the jsp page - JSP-Servlet
Unable to run the jsp page  Expert:Naga Hi, I need solution this program. In cart.jsp I printed the total amount of the products then the next... details should be stored in ?orders? table in the ?shopping ? data base
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; /** * * @author kwngeaw */ import javax.comm.*; import java.io.
Unable to call .jrxml file from jsp
Unable to call .jrxml file from jsp  Hi, I am doing web application in jsp. To create report I have used ireport and interated with neatbeans using... then it unable to access it.Error also not showing. I will show my code and its output
unable to compile class file - JSP-Servlet
unable to compile class file  I wrote database connection in jsp file.... In database i have a employeeid field. How can i display all employee id...("/jsp/Combobox.jsp"); dispatcher.forward(request, response
Struts2...problem in JSP..unable to get the values for menuTitle!!!
Struts2...problem in JSP..unable to get the values for menuTitle!!!  **Hello everyone... i'm trying to make a dynamic menu from database in struts2... Jsp is displaying the menuId from database but not the menuTitle...where as its
connect to the database from JSP
connect to the database from JSP  How do you connect to the database from JSP?   A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets
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 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... the answer to retrieve data from the database by using servlet or jsp program
unable to retrive the data from mysql using servlet using jdbc driver
unable to retrive the data from mysql using servlet using jdbc driver ... to the database"); stmt = con.createStatement(); rs...(request,response); } } .i am unable to redirect..here is the code..pls
jsp with excel sheet data uploading into database
jsp with excel sheet data uploading into database  how to upload data in excel sheet with jsp into oracle 10g database
Unable to run jsp files on internet explorer - JSP-Servlet
Unable to run jsp files on internet explorer  Hi, I am Akhilesh Shrivastav. I am new to jsp and a new member of this site. My problem is i wrote a small jsp program stored in the Web-Apps folder of Apache Tomcat. But i