Can't connect to Oracle XE instance from Java web application

Advertisement

I'm a long-time Java developer but can't figure this out.
I've been pouring over the forum for over a week and can't
find the solution that will let me connect.
Hardware: Intel/Vista.
DB: Oracle Express 10G.
Application: Java web application (Jakarta Struts)
Application Server: Tomcat 5.5
I copied the latest JDBC driver from OTN into my app server's "/LIB" directory.
I get no driver errors. ("ojdbc14.JAR)"
I can connect locally from my TOAD client, using SYSTEM/PASSWORD/XE.
My listeners seem to be OK.
Depending on which connection string I use from my Java application,
I get one of two messages.
"ORA-01017: invalid username/password; logon denied"
OR
"Io exception: The Network Adapter could not establish the connection"
------------ lsnrctl status ---------------------------------------------------
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
Instance "xe", status READY, has 1 handler(s) for this service...
Service "XE_XPT" has 1 instance(s).
Instance "xe", status READY, has 1 handler(s) for this service...
Service "xe" has 1 instance(s).
Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully
------------ SOURCE CODE ------------------------------------------------------
OracleDataSource ods = new OracleDataSource();
ods.setURL(" jdbc:oracle:thin:@localhost");
conn = ods.getConnection("system", "password");
//ods.setURL("jdbc:oracle:thin:@rsosborn-PC:1521:XE");
//conn = ods.getConnection("system", "password");
String query = "select * from books;";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);

Advertisement

Using the code you supplied I was able to reproduce your errors. I've adjusted it accordingly and can connect to one of my 10.2 test databases.
import java.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.*;
class Conn {
  public static void main (String args []) throws SQLException
    Connection conn = null;       
    OracleDataSource ods = new OracleDataSource();
    // ods.setURL(" jdbc:oracle:thin:@localhost:1521:TEST");
    // conn = ods.getConnection("scott", "tiger");
    ods.setURL("jdbc:oracle:thin:@localhost:1521:TEST");
    conn = ods.getConnection("scott", "tiger");
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
    while (rset.next())
        System.out.println (rset.getString(1));   // Print col 1
    stmt.close();
}There are several different ways to configure OracleDataSources:
http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/urls.htm#BEIDBFDF
So, hopefully it's just a mismatch config.

October 11, 2015

Can't connect to Oracle XE instance from Java web application

I'm a long-time Java developer but can't figure this out. I've been pouring over the forum for over a week and can't find the solution that will let me connect. Hardware: Intel/Vista. DB: Oracle Express 10G. Application: Java web application (Jakarta

How can I connect to multiple WLS instances from a single Apache virtual host

Configuration : WebLogic 5.1 SP8 & Apache I need to be able to have a configuration that looks something like this. www.company.com/x -> WL cluster01 www.company.com/y -> WL cluster02 In all the examples that I have been able to find they alway

Can't connect to my VPN server from the WAN addres...

I've setup a PPTP VPN server on a Raspberry Pi, so that I can connect to it when out and about and avoid having my android internet use sniffed by random public wi-fi hotspots. It seems to be working as I setup a Windows 7 connection to it using the

How can I stop the oracle XSLT processor from inserting extra whitespace in HTML?

How can I stop the oracle XSLT processor from inserting extra whitespace in HTML?Use <xsl:output mode="html" indent="no"/> as a top-level element child of your <xsl:stylesheet> element.Read other 3 answers

Installing JDBC driver to connect to Oracle 8i Database from Weblogic 10.3

I want to connect to Oracle 8i database from weblogic 10.3 application server. I found a classes12. zip file on Oracle.com to use as driver for the same. I am also connecting Oracle 9i database from the app server. Now if i replace the classes12. jar

TS1363 I can't connect to the itunes store from my Windows Vista PC. I have run diagnostics and itunes have verified my internet connection as positive, but not the secure link to the itunes store. This comes up as failed.  Any suggestions?

I can't connect to the itunes store from my Windows Vista PC. I have run diagnostics and itunes have verified my internet connection as positive, but not the secure link to the itunes store. This comes up as failed.  Any suggestions?everytime I try t

Oracle 6i Forms can't connect to Oracle XE Database(Linux)

What is the problem, I can't connect my Oracle 6i Forms to Oracle XE Database that installed on Linux(Fedora Core 4/Ubuntu 6.06), but no problem when I try to connect to Oracle XE Database that installed on Windows. Thanks,See this thread, seem me in

Problem in calling Oracle stored procedure from Java.

I am trying to invoke the Oracle stored procedure from Java. The procedure does not take any parameters and does not return anything. If I call it from SQL prompt it is working perfectly. I am calling it in my program as follows. callable_stmt=con.pr

How can I get my Aperture library back from the Photos application?

As stated above, How can I get my Aperture library back from the Photos application?  I'm not a fan of Photos right now and haven't used iPhoto in years, so that wasn't a loss... I didn't realize when I gave Photo's access to my Aperture library, I w

Pass data from one web application to another web application

Hi, Please provide suggestion for following scenario: Scenario: Basically the aim is to transfer large amount of data from one application to another and display JSP of second application. User enteres data on a JSP of one web application. When he su

Use VPN connection as a listen network interface in Web Application proxy

I have a test environment: domain in hyper-v with Sharepoint and Office Web Apps servers (all under Windows 2012 - Windows 2012 R2). Because my home ISP does not permit some inbound ports (80,443) in a gate machine (under Windows 2012 R2) I create a

Upraded Sql Developer and can't connect to Oracle

I just updated to the Dec 2009 release and now I can't connect When I click the plus or right click on Connections and select "New Connection" nothing happens. If I monitor processes in task manager it shows a brief spike in cpus and a small inc

Cannot connect to Oracle 11gR2 database from SQL Server 2005

Both SQL Server (Windows) and Oracle (Linux) are in 64bit environments. I have done the following on a Windows 2008 R2 with SQL Server 2005: Install InstantClient from Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (x64) to C

Can Crystal Connect to Oracle OLAP Cube

I have CR Professional XI installed.  Does it have the capability to connect to Oracle 10g OLAP Cubes created in Oracle AWM?Hi Tommyi,     For Oracle OLAP Cube, are we referring to Hyperien ESSbase?     If the answer is true, then we can create a con

Trouble connecting to Oracle 10g XE via Java

Greetings friends, As the thread title suggests, I'm trying to connect to the inbuilt HR schema that comes with Oracle 10 XE, via Java. This has implications for my work so any help is appreciated. From my limited knowledge, the drive appears to be t

How to Open an Oracle Apps Screen from a web page

Hi, We have requirement for Opening an Oracle Application screen (say sales order form) directly from a web page. I could get the URL of the required screen, but the URL contains an ICX_TICKET number, which is generated dynamically by Oracle Apps. So

Can not launch swing application from Java Web Start 1.6.0_37

I have a dynamic generated jnlp file from a serlvet. When I used Java Web Start to start the swing application, it failed. The exception showed com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://xxxx.xx.com:9080/dilpipweb/Tes

How can I open help file (HTML or .chm) from Java Web Start (new to JAVA)

Hi All, Im trying to open the help file of my application. When trying to access the help file from the GUI (pressing F1 for launching the help file), I'm geting the an error, something like: "Can't show help URL: jar:file:C:\Documents and Settings\%

Refresh an open web page on closing an applet launch from Java Web Start

Hi I launch an aplication via Java Web Start from a link in a web page. I am looking to a solution to refresh my web page when I close my applet. Thanks in advance to give me the solution or only to let me know if it's possible or not.everything's po

Open a SAPGUI transaction from a Java web application

Hi all,    We are in the process of developing a Java based web application with SAP J2EE engine - but not SAP Enterprise Portal. One of the requirements we have is from one of the web screens there needs to be a button which launches SAPGUI and take