Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java Open Source > Struts
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Struts section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 7th, 2006, 11:37 AM
Registered User
 
Join Date: Jun 2006
Location: , , India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connecting to oracle database in struts

Hi,
I'm new to this forum. I'm having trouble in connecting my web application to the oracle database. Can anyone guide me on the steps i need to follow to do the same? Also, does connecting to the database have any connection with the server i'm using? I was earlier using the Tomcat server, but now i'm using JBoss application server. I would appreciate if someone can answer my query at the earliest. I'm in need of urgent help. Thanks in advance!
Manvi

Reply With Quote
  #2 (permalink)  
Old June 28th, 2006, 02:14 PM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi manvi,
Please If u get answer let me know. Actualy i want to connect to oracle database and i have tomcat server. I am getting error. What jar file is needed? How to connect? Its urgent can u send me steps to connect?

Reply With Quote
  #3 (permalink)  
Old July 12th, 2006, 04:57 AM
Friend of Wrox
 
Join Date: Jan 2006
Location: San Francisco, CA, USA.
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I use oracle-jdbc-8.1.7.1.jar and Class.forName("oracle.jdbc.driver.OracleDriver").n ewInstance() for classloading.

Jon Emerson
http://blogs.adobe.com/jon.emerson/
Reply With Quote
  #4 (permalink)  
Old August 7th, 2006, 10:53 PM
Authorized User
 
Join Date: Aug 2006
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sachin.tathod
Default

Hi ,u can use following code to get connection with oracle database



public Connection getDBConnection(String dataSourceName, String dbName)
        throws PasskeyException {
        java.sql.Connection connection = null;
        long timeNowiS = System.currentTimeMillis();

        try {
            logger.debug("Just entering getdbcon get App Name "+timeNowiS);
            javax.sql.DataSource dataSource = null;

            if (dbContextlist.containsKey(dataSourceName)) {
                dataSource = (javax.sql.DataSource) dbContextlist.get(dataSourceName);
            } else {
                Context context = new InitialContext();
                dataSource = (javax.sql.DataSource) context.lookup(dataSourceName);
                dbContextlist.put(dataSourceName, dataSource);
                context.close();
            }
            //PerformanceTimer time1=new PerformanceTimer();
            String appName = PasskeyUtils.getAppName();
            logger.debug("getdbcon get App Name "+appName);
            String username = PropertyFileReader.getPasskeyProperty(dbName +"."+appName+
            ".username");
          String password = PropertyFileReader.getPasskeyProperty(dbName + "."+appName+
          ".pwd");
            if ((password == null) || password.trim().equals("")) {
                throw new SQLException("no password --for db " + dbName+"user****"+username+"=="+appName);
            }

            connection = dataSource.getConnection(username, password);
            connection.setCatalog(dbName);
        } catch (java.sql.SQLException sqlEx) {
            throw new PasskeyException("in servicelocator.getDBConnection",
                sqlEx);
        } catch (Exception genericEx) {
            throw new PasskeyException("in servicelocator.getDBConnection",
                genericEx);
        }
        logger.debug("Just exiting getdbcon get App Name "+timeNowiS+" and now it is "+System.currentTimeMillis());
        return connection;
    }


Thanks and Regards,
SACHIN S.TATHOD
Patni Computer System Ltd.
Magarpatta City, Cyber City,
Tower 3,Level I & II,
Hadapsar,Pune - 411028
Mobile No:- +91-9881239401
Email ID:- sachin.tathod@patni.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting MS Access using Struts roopesh_dubey Struts 0 February 18th, 2007 02:43 AM
Connecting Oracle Database with an ASP page krisvamshi Oracle ASP 3 November 14th, 2004 05:56 PM
Exception connecting to Oracle Database with JDBC celia05es Java Databases 1 March 31st, 2004 04:42 AM
Creating and connecting in a Oracle Database cutovoi Excel VBA 2 February 4th, 2004 07:06 PM
Connecting an oracle database kelitu Oracle 0 September 4th, 2003 09:18 AM



All times are GMT -4. The time now is 04:23 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.