So the string works in that it connects to the DB. I just get an error when I 
try and use the connection. 

I tested by providing an invalid password, and I did get a password invalid 
error from oracle in the stack trace. 

I think the issue is in the get connection call it must make some call to the 
db, that oracle does not like when used via JNDI but works fine when used via 
JDBC. 

Tony


________________________________
 From: "Propes, Barry L [via Tomcat]" <ml-node+s10n499223...@n6.nabble.com>
To: tsidhu <tsidh...@yahoo.com> 
Sent: Thursday, January 10, 2013 2:32 PM
Subject: RE: JNDI setup oracle 11 g
 

Hmmm. I didn't know that, I guess. 

Well, I wonder if that long string requires some kind of escape character to be 
inserted in it? 


-----Original Message----- 
From: tsidhu [mailto:[hidden email]] 
Sent: Thursday, January 10, 2013 1:22 PM 
To: [hidden email] 
Subject: Re: JNDI setup oracle 11 g 

Thanks Barry, 

The reason for the long dburl string is that this is an Oracle RAC (Clustered 
database). My understanding is that the "simple" dburl cannot be used for RAC 
databases. 

Also, I tried removing/adding the  validationQuery  from the context.xml, 
however that did not work either :(. 

When I researched the ORA-00911 error, it typically is thrown when you haven an 
invalid character in the query. However I get this error when trying to get a 
connection via the JNDI reference to the pool. 

The strange thing is that this works via a simple java program that directly 
uses the JDBC/Oracle driver. 

I can work around the issue by not using JNDI in the web app, however I am not 
then able to use pooling I guess. 

Tony 


________________________________ 
 From: "Propes, Barry L [via Tomcat]" <[hidden email]> 
To: tsidhu <[hidden email]> 
Sent: Thursday, January 10, 2013 1:09 PM 
Subject: RE: JNDI setup oracle 11 g 


Tony, 

I have a similar standalone Java app that hits Oracle 11g. 

At your line with the DBURL, I have something much more concise. 

Where you have 
public static final String DBURL = "jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = 
(PROTOCOL = TCP)(HOST = abc-def-scan.corp.xyz.com)(PORT = 1521)) (CONNECT_DATA 
= (SERVER = DEDICATED) (SERVICE_NAME = SAMPLE.WORLD) )  )"; 


I simply have: 
 String dbURL = "jdbc:oracle:thin:@dbservername.1526:servicename"; 

I set the rest of that string in my tnsnames.ora file - not sure if you're 
unable to do this or not. I'd think you'd do it there. 

Could that be where the error is stemming from? 

The rest of it looks correct to me. 



-----Original Message----- 
From: tsidhu [mailto:[hidden email]] 
Sent: Thursday, January 10, 2013 9:52 AM 
To: [hidden email] 
Subject: JNDI setup oracle 11 g 

Hello, 

I am able to connect to my database from a stand alone java program, however 
the same connection information throws an exception when used via JNDI. 

My stand alone app: 

import java.sql.* ;  // for standard JDBC programs 

public class TestCon { 
        public static final String DBDRIVER = "oracle.jdbc.OracleDriver" ; 
        public static final String DBURL = "jdbc:oracle:thin:@(DESCRIPTION = 
(ADDRESS = (PROTOCOL = TCP)(HOST = abc-def-scan.corp.xyz.com)(PORT = 1521)) 
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SAMPLE.WORLD) )  )"; 
        public static final String DBUSER = "user1" ; 
        public static final String DBPASS = "pass1" ; 
        /** 
         * @param args 
         */ 
        public static void main(String[] args) { 

                Connection conn = null ;    // DB CONNECTIONS 
                PreparedStatement pstmt = null ;//  DB  OPERATIONS 
                ResultSet rs = null ;       //  save the query result 

                try { 
                        Class.forName(DBDRIVER) ; 

                        conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) 
; 
                        String sql = "select abc from xyz" ;   //sample query 
                        Statement stmt = conn.createStatement() ;   // execute 
the query and save 
the result 
                        rs = stmt.executeQuery(sql); 

                        rs.close(); 
                        stmt.close(); 
                        conn.close(); 

                } catch (ClassNotFoundException e) { 
                        // TODO Auto-generated catch block 
                        e.printStackTrace(); 
                }   // Load the ORACLE DRIVER 
                catch(SQLException sql) 
                 { 
                        // TODO Auto-generated catch block 
                        sql.printStackTrace(); 
                } 
        } 
} 

MY JNDI / Context.xml configuration 

<Resource name="jdbc/myoracle" auth="Container" 
      type="javax.sql.DataSource" 
                description="Oracle Datasource" 
                driverClassName="oracle.jdbc.OracleDriver" 

url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=abc-def-scan.corp.xyz.com)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SAMPLE.WORLD)))"
 
username="user1" password="pass1" maxActive="20" maxIdle="10" maxWait="-1" 
                validationQuery = "SELECT 1 FROM DUAL" /> 

The error I get when trying to run the following code from a servlet: 

                try { 
                        Context initContext = new InitialContext(); 
                        Context envContext = (Context) 
initContext.lookup("java:/comp/env"); 
                        DataSource ds = (DataSource) 
envContext.lookup("jdbc/myoracle"); 
                        Connection conn = ds.getConnection(); 

                        conn.close(); 
                        conn = null; 
                } 

ERROR 

Jan 10, 2013 10:47:25 AM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 1249 ms 
java.sql.SQLSyntaxErrorException: ORA-00911: invalid character 

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445) 
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) 
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879) 
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450) 
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192) 
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531) 
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193) 
        at 
oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java: 
873) 
        at 
oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStateme 
nt.java:1167) 
        at 
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStateme 
nt.java:1289) 
        at 
oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.ja 
va:1909) 
        at 
oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871) 

        at 
oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrap 
per.java:318) 
        at 
org.apache.tomcat.dbcp.dbcp.DelegatingStatement.execute(DelegatingSta 
tement.java:264) 
        at 
org.apache.tomcat.dbcp.dbcp.DelegatingStatement.execute(DelegatingSta 
tement.java:264) 
        at 
com.xyz.collections.controller.TestConnection.doGet(TestConnection.ja 
va:43) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl 
icationFilterChain.java:305) 
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF 
ilterChain.java:210) 
        at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV 
alve.java:222) 


The query runs fine when used in a stand alone java app, and I have tried all 
things in the Context.XML to resolve. 
I know it connects fine to the DB, however the getConnection from the JNDI 
datasource is causing that error to be thrown. 

Tony 





-- 
View this message in context: 
http://tomcat.10.n6.nabble.com/JNDI-setup-oracle-11-g-tp4992221.html
Sent from the Tomcat - User mailing list archive at Nabble.com. 

--------------------------------------------------------------------- 
To unsubscribe, e-mail: [hidden email] 
For additional commands, e-mail: [hidden email] 


--------------------------------------------------------------------- 
To unsubscribe, e-mail: [hidden email] 
For additional commands, e-mail: [hidden email] 



________________________________ 

If you reply to this email, your message will be added to the discussion 
below:http://tomcat.10.n6.nabble.com/JNDI-setup-oracle-11-g-tp4992221p4992228.html
To unsubscribe from JNDI setup oracle 11 g, click here. 
NAML 



-- 
View this message in context: 
http://tomcat.10.n6.nabble.com/JNDI-setup-oracle-11-g-tp4992221p4992234.html
Sent from the Tomcat - User mailing list archive at Nabble.com. 

--------------------------------------------------------------------- 
To unsubscribe, e-mail: [hidden email] 
For additional commands, e-mail: [hidden email] 



________________________________
 
If you reply to this email, your message will be added to the discussion 
below:http://tomcat.10.n6.nabble.com/JNDI-setup-oracle-11-g-tp4992221p4992236.html
 
To unsubscribe from JNDI setup oracle 11 g, click here.
NAML



--
View this message in context: 
http://tomcat.10.n6.nabble.com/JNDI-setup-oracle-11-g-tp4992221p4992240.html
Sent from the Tomcat - User mailing list archive at Nabble.com.

Reply via email to