Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem accessing datasource 1

Status
Not open for further replies.

sandybasic

IS-IT--Management
Oct 30, 2001
1
US
I'm not able to get datasource connection out of datasource pool. I created datasource in Websphere Standard edition v3.5. Used Oracle 8.1.5 as database. The format of connection string i used in Websphere is
jdbc:eek:racle:thin:<user name>/<password>@<host>:<port>:<sid>

But when i access this string from Java class using JDBC 2.0 APIs [connection = datasource.getConnection()], it throws an exception saying:

java.sql.SQLException: Io exception: Invalid connection string format, a valid format is: &quot;host:port:sid&quot;

The lookup for datasource using datasource = (DataSource)context.lookup(DATASOURCE_NAME) is working fine.

Can anybody help me out.. is it a problem with Oracle driver or websphere settings or my code itself??

 
Hi.

I think your connection string it's wrong.
When you create a dataSource, you don't have to specify user and password.

Try
jdbc:eek:racle:thin:mad:hostName:port:serviceId

UserId and password will be required as you ask the DataSource for a connection :
dataSource.getConnection(user,password);

Hope this helps!

Wonder
 
I am also having difficulty with a Datasource. I am using WAS 3.5.2 connecting to Informix 9.1 (and I know that it isn't supported until 4.0, but I can't upgrade to 4.0 just yet)

I have a datasource connection using a JDBC driver from Informix. I have verified that the driver is in the jar file and that the jar file IS in the class path, but WAS still gives the following error message in the stdout.log:

[01.12.06 13:53:37:613 MST] cefbc922 PortabilityLa W Unrecognized database or driver &quot;com.informix.jdbc.IfxDriver&quot;; using generic settings
[01.12.06 13:53:39:188 MST] cefbc922 PortabilityLa W Unrecognized database or driver &quot;Informix Dynamic Server&quot;; using generic settings


The really weird thing is that the &quot;generic settings&quot; do allow for connection to the database and we can read/write records just fine. Maybe I don't need to worry about it, but the driver should work and it isn't. I'm just trying to figure out what's going on.

Einstein47
(The greatest trick the devil ever did was to convice the world he didn't exists.)
 
Hi.

It seems that Ws recognizes only Db2 (try guessing why...:)))

I think you shouldn't worry about that for the same thing happens using jdbc-odbc bridge with SqlServer 7.

However, ensure you've installed the driver in the node (using Administrator's console, by right-clicking over the jdbc driver it will prompt you to install the driver)!

Hope this helps,
Uonder
 
Thanks for the help. I get the error message:

com.ibm.ejs.sm.exception.JDBCDriverAlreadyInstalled

I guess that means that everything has been done correctly, but WAS 3.5 only likes DB2 (and maybe Oracle).

I appreciate the help.
Einstein47
(The greatest trick the devil ever did was to convice the world he didn't exists.)
 
Create a JDBC DriverGeneral Tab
Name AnyDriver
ClassName oracle.jdbc.driver.OracleDriver
URL Prefix jdbc:eek:racle:thin:mad:hostname:portNumber
Path for JDBC /usr/local/opt/oracle/jdbc/lib/classes12.zip


Create a DataSource
Data Source Name AnyDataSource
DatabaseName instanceName
Driver AnyDriver

Add the datasource to the node that you have your servlet/EJB on.


Code to using the dataSource
java.sql.Connection dbCon = null;
java.sql.ResultSet rs = null;
java.sql.Statement stmt = null;
javax.sql.DataSource oracleDataSource null;
java.lang.String URL = &quot;/jdbc/AnyDataSource&quot;;

try {
javax.naming.Context ctx = new javax.naming.InitialContext();
oracleDataSource = ((javax.sql.DataSource)ctx.lookup(URL));
dbCon = oracleDataSource.getConnection(&quot;userName&quot;, &quot;password&quot;);
} catch (Exception e) {
System.out.println(&quot;Connection to Oracle Database cannot be Obtained&quot;+e);
}


try {
stmt = dbCon.createStatement();
rs = stmt.executeQuery(&quot;SELECT SYSDATE FROM dual&quot;);

if (rs.next()) {
System.out.println(rs.getDate(1).toString());
}
} catch (java.sql.SQLException e) {
System.out.println(&quot;Unable to get date&quot; + e);
}


 
I am using Oracle as DataSource. I am getting the following
error while starting one Entity Bean.

Exception:
Io exception: Invalid connection string format, a valid format is: &quot;host:port:sid&quot; java.sql.SQLException: Io exception: Invalid connection string format, a valid format is: &quot;host:port:sid&quot;

I have given the Connection String As
&quot;java.oracle.thin:mad:<host>:<port>:<sid>&quot;

and node has been installed with the JDBC Drive
for Oracle

pravle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top