Re: JNDI/Tomcat question from newbie

2005-09-01 Thread David Smith
Personally, I'd just keep a reference to the datasource around maybe as
a class instance variable.  It doesn't constitute a connection in and of
itself -- just a way of getting one from the pool.  Connections on the
other hand should be explicitly closed as soon as they aren't needed
anymore in any method that get's one.

--David

Hyatt, Gordon wrote:

>Hello All,
>
>I'm a newbie to database pooling via JNDI and I have a JNDI/Tomcat question 
>(more of a "best practices"/most scalable/fastest performance/least resource 
>consumption type of question).
>
>Each time the JNDI resource (pooled database connection) is needed, should a 
>complete JNDI lookup be performed or can part of the lookup be "cached"?  For 
>example, should the code be:
>
>
>Context initCtx = new InitialContext ();
>Context envCtx = (Context)initCtx.lookup ("java:comp/env");
>ds = (DataSource)envCtx.lookup ("jdbc/data_source_name");
>
>
>
>or can the java:comp/env Context be saved as an attribute in the servlet 
>context and a (synchronized) code segment like the following be used to obtain 
>the DataSource?
>
>
>Context ctx = (Context)ctxFromServletContext.lookup ("");
>ds = (DataSource)ctx.lookup ("jdbc/data_source_name");
>
>
>Thus far, I haven't read anything about which method is acceptable/preferred 
>or if one method yields significant performance benefit.  
>
>Since, according to the docs a Context is not guaranteed to be synchronized 
>against concurrent access by multiple threads, I assume that the first code 
>segment above should be synchronized, especially if it is in a static method.
>
>Thanks in advance,
>
>Gord 
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>  
>


-- 
===
David Smith
Network Operations Supervisor
Department of Entomology
College of Agriculture & Life Sciences
Cornell University
2132 Comstock Hall
Ithaca, NY  14853
Phone: 607.255.9571
Fax: 607.255.0939


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



JNDI/Tomcat question from newbie

2005-09-01 Thread Hyatt, Gordon
Hello All,

I'm a newbie to database pooling via JNDI and I have a JNDI/Tomcat question 
(more of a "best practices"/most scalable/fastest performance/least resource 
consumption type of question).

Each time the JNDI resource (pooled database connection) is needed, should a 
complete JNDI lookup be performed or can part of the lookup be "cached"?  For 
example, should the code be:


Context initCtx = new InitialContext ();
Context envCtx = (Context)initCtx.lookup ("java:comp/env");
ds = (DataSource)envCtx.lookup ("jdbc/data_source_name");



or can the java:comp/env Context be saved as an attribute in the servlet 
context and a (synchronized) code segment like the following be used to obtain 
the DataSource?


Context ctx = (Context)ctxFromServletContext.lookup ("");
ds = (DataSource)ctx.lookup ("jdbc/data_source_name");


Thus far, I haven't read anything about which method is acceptable/preferred or 
if one method yields significant performance benefit.  

Since, according to the docs a Context is not guaranteed to be synchronized 
against concurrent access by multiple threads, I assume that the first code 
segment above should be synchronized, especially if it is in a static method.

Thanks in advance,

Gord 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI - TOMCAT ------ success

2005-07-27 Thread Kane Wilson
Tim , it was success. thanx million. earlier i referred 5.0 docs. anyway it was 
my fault. again i would like to thank you Tim. It is great help
 
Kane.
 
  

Tim Funk <[EMAIL PROTECTED]> wrote:
Don't use docs based on 4.1 when running 5.5.

Use the 5.5 docs. The way JNDI resources are declared in 5.5 changed as 
compared to previous versions. The archives in the tomcat user list also talk 
about this too.
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/index.html

-Tim

Kane Wilson wrote:

> Hi List , 
> 
> This is actually problem with JNDI . I'm tring to connect to mysql database 
> via JNDI in tomcat 5.5.9. First of all 
> i installed tomcat 5.5.9 in my windows 2000 advance server machine and 
> accrding to guide of 
> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
>  url , I have done every thng 
> according to the article.
> my sql connector is mysql-connector-java-3.1.10-bin.jar C:\Tomcat\common\lib
> after all the steps get done , i pointed to the test.jsp
> but i got an error saying ,
> DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot 
> create JDBC driver of class '' for 
> connect URL 'null'"
> ===
> so then i surf the internet to findout a soloution , there are plenty of such 
> issues and some closest solutions 
> with crerating .war files , changing some parameters like that .
> http://www.theserverside.com/tss?service=direct/0/DiscussionThread/threadViewer.bookmark.link&sp=l29795
> but , i would like to ask from directly from jakarta.apache.org/tomcat , do u 
> have sudgested a solution for this 
> matter / problem ? is it a bug in that particular version ( 5.5.9 ) ? do i 
> have to switched for another version ?
> is that problem of curruption of mysql connector ? 
> can i findout any one who has already solved this issue ?
> I read well FAQ's rules and regulations . i agreed with that . and i think , 
> this issue has discussed couple of 
> times in this list. but i cant findout exactly how could be the solution was 
> ! .
> Please help me , it's really appreciate if u guys can consider this problem 
> deeply .
> 
> Thanx in advance for Tomcat and the LIST ,
> Kane.
> 
> 
> -
> Start your day with Yahoo! - make it your home page 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: JNDI - TOMCAT

2005-07-27 Thread Tim Funk

Don't use docs based on 4.1 when running 5.5.

Use the 5.5 docs. The way JNDI resources are declared in 5.5 changed as 
compared to previous versions. The archives in the tomcat user list also talk 
about this too.

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/index.html

-Tim

Kane Wilson wrote:

Hi List , 
 
This is actually problem with JNDI . I'm tring to connect to mysql database via JNDI in tomcat 5.5.9. First of all 
i installed tomcat 5.5.9 in my windows 2000 advance server machine and accrding to guide of  
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html url , I  have done every thng 
according to the article.

my sql connector is mysql-connector-java-3.1.10-bin.jar C:\Tomcat\common\lib
after all the steps get done , i pointed to the  test.jsp
but i got an error saying ,
DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for 
connect URL 'null'"

===
so then i surf the internet to findout a soloution , there are plenty of such issues and some closest solutions  
with crerating .war files , changing some parameters like that .

http://www.theserverside.com/tss?service=direct/0/DiscussionThread/threadViewer.bookmark.link&sp=l29795
but , i would like to ask from directly  from jakarta.apache.org/tomcat  , do u have sudgested a solution for this 
matter / problem ? is it a bug in that particular version ( 5.5.9 ) ? do i have to switched for another version ?
is that problem of curruption of mysql connector ? 
can i findout any one who has already solved this issue ?
I read well FAQ's rules and regulations . i agreed with that . and i think , this issue has discussed couple of 
times in this list. but i cant findout exactly how could be the solution was ! .

Please help me , it's really appreciate if u guys can consider this problem 
deeply .
 
Thanx in advance for Tomcat and the LIST ,

Kane.


-
 Start your day with Yahoo! - make it your home page 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



JNDI - TOMCAT

2005-07-27 Thread Kane Wilson
Hi List , 
 
This is actually problem with JNDI . I'm tring to connect to mysql database via 
JNDI in tomcat 5.5.9. First of all 
i installed tomcat 5.5.9 in my windows 2000 advance server machine and accrding 
to guide of  
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
 url , I  have done every thng 
according to the article.
my sql connector is mysql-connector-java-3.1.10-bin.jar C:\Tomcat\common\lib
after all the steps get done , i pointed to the  test.jsp
but i got an error saying ,
DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot 
create JDBC driver of class '' for 
connect URL 'null'"
===
so then i surf the internet to findout a soloution , there are plenty of such 
issues and some closest solutions  
with crerating .war files , changing some parameters like that .
http://www.theserverside.com/tss?service=direct/0/DiscussionThread/threadViewer.bookmark.link&sp=l29795
but , i would like to ask from directly  from jakarta.apache.org/tomcat  , do u 
have sudgested a solution for this 
matter / problem ? is it a bug in that particular version ( 5.5.9 ) ? do i have 
to switched for another version ?
is that problem of curruption of mysql connector ? 
can i findout any one who has already solved this issue ?
I read well FAQ's rules and regulations . i agreed with that . and i think , 
this issue has discussed couple of 
times in this list. but i cant findout exactly how could be the solution was 
! .
Please help me , it's really appreciate if u guys can consider this problem 
deeply .
 
Thanx in advance for Tomcat and the LIST ,
Kane.


-
 Start your day with Yahoo! - make it your home page 

RE: JNDI + Tomcat + Oracle 9i Database

2003-02-25 Thread pqin
This issue has been asked and answered again and again in the mailing list
of tomcat, struts, and commons. Consider that Oracle is so populate, setup
should be pretty straightforward.

My advice is to make sure that you have read carefully the tomcat datasource
documentation.

My environment is

J2sdk 1.4.1_01 <= 1.4
Tomcat 4.1.18
Apache 2.0.44
Tomcat Connector 2.0.3
Red Hat Linux 7.2 (prod)
Windows 2000 (dev)
Oracle 8.1.7
classes12.jar <= 1.2

1. Below is part of my context. Do not invent the resource type, driver, and
factory. I saw someone use a different factory or driver think they are
going to utilize Oracle's pooling. It is smart but it is wrong in this case.
To prove it is wrong, read Tomcat source code.

 



driverClassName
oracle.jdbc.driver.OracleDriver


url
jdbc:oracle:thin:@oratest.int.abcd.com:1521:PROD


2. Also in my app's web.xml


Oracle Datasource
jdbc/abcd
javax.sql.DataSource
Container


Do not put commons-dbcp and pooling jars in your app's WEB-INF/lib, use
Tomcat's (in common/lib).

3. Initialize the connection pool and get connection:

Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:comp/env");
DataSource dataSource = (DataSource) envContext.lookup("jdbc/abcd");
dataSource.getConnection()

Don't do anything other than point 3 to get the connection or driver.

I have had two problems before:

- null driver: renamed classes12.zip to classes12.jar and put it ONLY in
commons/lib.
- cannot connect: use a real url other than Microsoft's name, so oratest
won't work on linux while oratest.mydomain.com works.
- cast exception: use commons dbcp and pooling in commons/lib.


Regards,
 
 
PQ
 
"This Guy Thinks He Knows Everything"
"This Guy Thinks He Knows What He Is Doing"

-Original Message-
From: "Sebastião Carlos Santos" [mailto:[EMAIL PROTECTED] 
Sent: February 25, 2003 1:37 PM
To: [EMAIL PROTECTED]
Subject: Re: JNDI + Tomcat + Oracle 9i Database

When I made the change of the url  for URL  I
started to receive the following error message  
Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' it goes
connect URL 'null'  
Going back to the configuration url   
Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' it goes
connect URL 'jdbc:oracle:[EMAIL PROTECTED]:1521:GED'

Taking advantage of the opportunity, which driver JDBC should use,
ojdbc14.jar (for the jdk 1.4) or classes12.zip, that should have the name
according to the documentation changed for classes12.jar

Sebastião Carlos Santos
Oracle Database Administrator 
Universidade Federal de Uberlândia - UFU
Gratificação de Estímulo à Docência - GED



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: JNDI + Tomcat + Oracle 9i Database

2003-02-25 Thread "Sebastião Carlos Santos"
Kris,
 I believe that I went badly interpreted or I wrote of less in the e-mail. I don't see 
him/it why of installing the customer of Oracle 9i in the application servant for the 
simple fact most of the time, after the installation routines we have to specify the 
files. zip and. jar copied in the installation for ORACLE_HOME in CLASSPATH of the 
system, which in other words it would be the same thing of using the drivers jdbc 
supplied separately.
 I didn't have the intention of contradicting the positioning for you put.
 Respectfully,
Sebastião Carlos Santos
Oracle Database Administrator
Universidade Federal de Uberlândia - UFU
Gratificação de Estímulo à Docência - GED



Re: JNDI + Tomcat + Oracle 9i Database

2003-02-25 Thread "Sebastião Carlos Santos"
When I made the change of the url  for URL  I started to 
receive the following error message
Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' it goes connect 
URL 'null'
Going back to the configuration url 
Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' it goes connect 
URL 'jdbc:oracle:[EMAIL PROTECTED]:1521:GED'

Taking advantage of the opportunity, which driver JDBC should use, ojdbc14.jar (for 
the jdk 1.4) or classes12.zip, that should have the name according to the 
documentation changed for classes12.jar

Sebastião Carlos Santos
Oracle Database Administrator
Universidade Federal de Uberlândia - UFU
Gratificação de Estímulo à Docência - GED



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI + Tomcat + Oracle 9i Database

2003-02-25 Thread Mehdi . Nejad

Hi [difficult name ommited],

I had this problem a couple of weeks ago.

try changing the url to capitals !

URL

This fixed an identical problem for me.

Thanks,

Mehdi Nejad



   
   
  "Sebastião Carlos
   
  Santos"  To:   [EMAIL PROTECTED] 
  
  <[EMAIL PROTECTED]cc:

  .com.br>     Subject:  JNDI + Tomcat + Oracle 9i 
Database   
   
   
  25/02/2003 15:02 
   
  Please respond to
   
  "Tomcat Users
   
  List"
   
   
   
   
   




I am trying to configure JNDI to access Oracle 9i R1,
according to JNDI Datasource HOW-TO,
however I am not obtaining a lot of success when I go
to establish the connection.

In the end of this e-mail I will list some fragments of the configuration
of server.xml,
web.xml and of my class java that I am using to accomplish the connection
test.

The reference $CATALINA_HOME/common/lib/*. jar is in CLASSPATH of the
system

Fragment of configuration of server.xml

...
  
  
factory

org.apache.commons.dbcp.BasicDataSourceFactory
driverClassName
  oracle.jdbc.driver.OracleDriver
url

jdbc:oracle:[EMAIL PROTECTED]:1521:XXX

usernamescott

passwordj
maxActive20
maxIdle10
maxWait1

removeAbandonedtrue

removeAbandonedTimeout60

logAbandonedtrue
  
...

File /web/WEB-INF/web.xml


  http://java.sun.com/dtd/web-app_2_3.dtd";>
  
Oracle Database Connection

  Pool
  jdbc/sged
  javax.sql.DataSource
  Container


  index.html
  index.jsp
  index.htm

  


Method of the class java that makes the connection test

public String obtem_dados()
{
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
resultado = new StringBuffer();
try
{
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup
("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup
("jdbc/sged");
conn = ds.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery("SELECT COUNT(*) FROM
V$SESSION");
if (rset.next())
{
resultado.append("Número de Conexões -> ");
resultado.append(rset.getString(1));
resultado.append("");
}
}
catch (java.lang.Exception e)
{
resultado.append(e.getMessage());
resultado.append("");
}
finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (java.lang.Exception ex)
{
resultado.append(ex.getMessage());
resultado.append("");
}
}
}
return ((resultado.toString()));
}

Ao executar o método anterio

JNDI + Tomcat + Oracle 9i Database

2003-02-25 Thread "Sebastião Carlos Santos"
I am trying to configure JNDI to access Oracle 9i R1,
according to JNDI Datasource HOW-TO,
however I am not obtaining a lot of success when I go
to establish the connection.

In the end of this e-mail I will list some fragments of the configuration of 
server.xml,
web.xml and of my class java that I am using to accomplish the connection test.

The reference $CATALINA_HOME/common/lib/*. jar is in CLASSPATH of the system

Fragment of configuration of server.xml

...
  
  
factory
  org.apache.commons.dbcp.BasicDataSourceFactory
driverClassName
  oracle.jdbc.driver.OracleDriver
url
  jdbc:oracle:[EMAIL PROTECTED]:1521:XXX
usernamescott
passwordj
maxActive20
maxIdle10
maxWait1
removeAbandonedtrue
removeAbandonedTimeout60
logAbandonedtrue
  
...

File /web/WEB-INF/web.xml


  http://java.sun.com/dtd/web-app_2_3.dtd";>
  
Oracle Database Connection

  Pool
  jdbc/sged
  javax.sql.DataSource
  Container


  index.html
  index.jsp
  index.htm

  


Method of the class java that makes the connection test

public String obtem_dados()
{
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
resultado = new StringBuffer();
try
{
Context initContext = new InitialContext();
Context envContext = 
(Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/sged");
conn = ds.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery("SELECT COUNT(*) FROM V$SESSION");
if (rset.next())
{
resultado.append("Número de Conexões -> ");
resultado.append(rset.getString(1));
resultado.append("");
}
}
catch (java.lang.Exception e)
{
resultado.append(e.getMessage());
resultado.append("");
}
finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (java.lang.Exception ex)
{
resultado.append(ex.getMessage());
resultado.append("");
}
}
}
return ((resultado.toString()));
}

Ao executar o método anterior, recebo a seguinte mensagem de erro:

Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL 
jdbc:oracle:[EMAIL PROTECTED]:1521:XXX

Alguém tem alguma idéia do que pode estar acontecendo?

Excuse me for the gigantic message.
I thank in advance.
Sebastião Carlos Santos
Oracle Database Administrator
Universidade Federal de Uberlândia - UFU
Gratificação de Estímulo à Docência - GED



JNDI + Tomcat + Oracle 9i Database

2003-02-25 Thread "Sebastião Carlos Santos"
I am trying to configure JNDI to access Oracle 9i R1,
according to JNDI Datasource HOW-TO,
however I am not obtaining a lot of success when I go
to establish the connection.

In the end of this e-mail I will list some fragments of the configuration of 
server.xml,
web.xml and of my class java that I am using to accomplish the connection test.

The reference $CATALINA_HOME/common/lib/*. jar is in CLASSPATH of the system

Fragment of configuration of server.xml

...
  
  
factory
  org.apache.commons.dbcp.BasicDataSourceFactory
driverClassName
  oracle.jdbc.driver.OracleDriver
url
  jdbc:oracle:[EMAIL PROTECTED]:1521:XXX
usernamescott
passwordj
maxActive20
maxIdle10
maxWait1
removeAbandonedtrue
removeAbandonedTimeout60
logAbandonedtrue
  
...

File /web/WEB-INF/web.xml


  http://java.sun.com/dtd/web-app_2_3.dtd";>
  
Oracle Database Connection

  Pool
  jdbc/sged
  javax.sql.DataSource
  Container


  index.html
  index.jsp
  index.htm

  


Method of the class java that makes the connection test

public String obtem_dados()
{
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
resultado = new StringBuffer();
try
{
Context initContext = new InitialContext();
Context envContext = 
(Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/sged");
conn = ds.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery("SELECT COUNT(*) FROM V$SESSION");
if (rset.next())
{
resultado.append("Número de Conexões -> ");
resultado.append(rset.getString(1));
resultado.append("");
}
}
catch (java.lang.Exception e)
{
resultado.append(e.getMessage());
resultado.append("");
}
finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (java.lang.Exception ex)
{
resultado.append(ex.getMessage());
resultado.append("");
}
}
}
return ((resultado.toString()));
}

Ao executar o método anterior, recebo a seguinte mensagem de erro:

Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL 
jdbc:oracle:[EMAIL PROTECTED]:1521:XXX

Alguém tem alguma idéia do que pode estar acontecendo?

Excuse me for the gigantic message.
I thank in advance.
Sebastião Carlos Santos
Oracle Database Administrator
Universidade Federal de Uberlândia - UFU
Gratificação de Estímulo à Docência - GED



JNDI + Tomcat + Oracle 9i Database

2003-02-25 Thread "Sebastião Carlos Santos"
I am trying to configure JNDI to access Oracle 9i R1,
according to JNDI Datasource HOW-TO,
however I am not obtaining a lot of success when I go
to establish the connection.

In the end of this e-mail I will list some fragments of the configuration of 
server.xml,
web.xml and of my class java that I am using to accomplish the connection test.

Files in $CATALINA_HOME/common/lib
[EMAIL PROTECTED]:/usr/local/jakarta-tomcat-4.1.18/common/lib > ls
activation.jar  commons-collections.jar  commons-pool.jar jdbc2_0-stdext.jar  
mail.jarnaming-resources.jar
ant.jar commons-dbcp.jar jasper-compiler.jar  jndi.jar
naming-common.jar   ojdbc14.jar
classes12.jar   commons-logging-api.jar  jasper-runtime.jar   jta.jar 
naming-factory.jar  servlet.jar

The reference $CATALINA_HOME/common/lib/*. jar is in CLASSPATH of the system

Fragment of configuration of server.xml







  

  

  

  

  
  
usernamesa
password
driverClassName
  org.hsql.jdbcDriver
url
  jdbc:HypersonicSQL:database
  

  
  
factory
  org.apache.commons.dbcp.BasicDataSourceFactory
driverClassName
  oracle.jdbc.driver.OracleDriver
url
  jdbc:oracle:[EMAIL PROTECTED]:1521:XXX
usernamescott
passwordj
maxActive20
maxIdle10
maxWait1
removeAbandonedtrue
removeAbandonedTimeout60
logAbandonedtrue
  

  
  

  mail.smtp.host
  localhost

  
  


  

File /web/WEB-INF/web.xml


  http://java.sun.com/dtd/web-app_2_3.dtd";>
  
Oracle Database Connection

  Pool
  jdbc/sged
  javax.sql.DataSource
  Container


  index.html
  index.jsp
  index.htm

  


Method of the class java that makes the connection test

public String obtem_dados()
{
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
resultado = new StringBuffer();
try
{
Context initContext = new InitialContext();
Context envContext = 
(Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/sged");
conn = ds.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery("SELECT COUNT(*) FROM V$SESSION");
if (rset.next())
{
resultado.append("Número de Conexões -> ");
resultado.append(rset.getString(1));
resultado.append("");
}
}
catch (java.lang.Exception e)
{
resultado.append(e.getMessage());
resultado.append("");
}
finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (java.lang.Exception ex)
{
resultado.append(ex.getMessage());
resultado.append("");
}
}
}
return ((resultado.toString()));
}

Ao executar o método anterior, recebo a seguinte mensagem de erro:

Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL 
'jdbc:oracle:[EMAIL PROTECTED]:1521:GED'

Alguém tem alguma idéia do que pode estar acontecendo?

Excuse me for the gigantic message.
I thank in advance.
Sebastião Carlos Santos
Oracle Database Administrator
Universidade Federal de Uberlândia - UFU
Gratificação de Estímulo à Docência - GED



JNDI + Tomcat + Oracle 9i Database

2003-02-25 Thread "Sebastião Carlos Santos"
I am trying to configure JNDI to access Oracle 9i R1,
according to JNDI Datasource HOW-TO,
however I am not obtaining a lot of success when I go
to establish the connection.

In the end of this e-mail I will list some fragments of the configuration of 
server.xml,
web.xml and of my class java that I am using to accomplish the connection test.

Files in $CATALINA_HOME/common/lib
[EMAIL PROTECTED]:/usr/local/jakarta-tomcat-4.1.18/common/lib > ls
activation.jar  commons-collections.jar  commons-pool.jar jdbc2_0-stdext.jar  
mail.jarnaming-resources.jar
ant.jar commons-dbcp.jar jasper-compiler.jar  jndi.jar
naming-common.jar   ojdbc14.jar
classes12.jar   commons-logging-api.jar  jasper-runtime.jar   jta.jar 
naming-factory.jar  servlet.jar

The reference $CATALINA_HOME/common/lib/*. jar is in CLASSPATH of the system

Fragment of configuration of server.xml







  

  

  

  

  
  
usernamesa
password
driverClassName
  org.hsql.jdbcDriver
url
  jdbc:HypersonicSQL:database
  

  
  
factory
  org.apache.commons.dbcp.BasicDataSourceFactory
driverClassName
  oracle.jdbc.driver.OracleDriver
url
  jdbc:oracle:[EMAIL PROTECTED]:1521:XXX
usernamescott
passwordj
maxActive20
maxIdle10
maxWait1
removeAbandonedtrue
removeAbandonedTimeout60
logAbandonedtrue
  

  
  

  mail.smtp.host
  localhost

  
  


  

File /web/WEB-INF/web.xml


  http://java.sun.com/dtd/web-app_2_3.dtd";>
  
Oracle Database Connection

  Pool
  jdbc/sged
  javax.sql.DataSource
  Container


  index.html
  index.jsp
  index.htm

  


Method of the class java that makes the connection test

public String obtem_dados()
{
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
resultado = new StringBuffer();
try
{
Context initContext = new InitialContext();
Context envContext = 
(Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/sged");
conn = ds.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery("SELECT COUNT(*) FROM V$SESSION");
if (rset.next())
{
resultado.append("Número de Conexões -> ");
resultado.append(rset.getString(1));
resultado.append("");
}
}
catch (java.lang.Exception e)
{
resultado.append(e.getMessage());
resultado.append("");
}
finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (java.lang.Exception ex)
{
resultado.append(ex.getMessage());
resultado.append("");
}
}
}
return ((resultado.toString()));
}

Ao executar o método anterior, recebo a seguinte mensagem de erro:

Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL 
'jdbc:oracle:[EMAIL PROTECTED]:1521:GED'

Alguém tem alguma idéia do que pode estar acontecendo?

Excuse me for the gigantic message.
I thank in advance.
Sebastião Carlos Santos
Oracle Database Administrator
Universidade Federal de Uberlândia - UFU
Gratificação de Estímulo à Docência - GED



JNDI + Tomcat + Oracle 9i Database

2003-02-25 Thread "Sebastião Carlos Santos"
I am trying to configure JNDI to access Oracle 9i R1,
according to JNDI Datasource HOW-TO,
however I am not obtaining a lot of success when I go
to establish the connection.

In the end of this e-mail I will list some fragments of the configuration of 
server.xml,
web.xml and of my class java that I am using to accomplish the connection test.

Files in $CATALINA_HOME/common/lib
[EMAIL PROTECTED]:/usr/local/jakarta-tomcat-4.1.18/common/lib > ls
activation.jar  commons-collections.jar  commons-pool.jar jdbc2_0-stdext.jar  
mail.jarnaming-resources.jar
ant.jar commons-dbcp.jar jasper-compiler.jar  jndi.jar
naming-common.jar   ojdbc14.jar
classes12.jar   commons-logging-api.jar  jasper-runtime.jar   jta.jar 
naming-factory.jar  servlet.jar

The reference $CATALINA_HOME/common/lib/*. jar is in CLASSPATH of the system

Fragment of configuration of server.xml







  

  

  

  

  
  
usernamesa
password
driverClassName
  org.hsql.jdbcDriver
url
  jdbc:HypersonicSQL:database
  

  
  
factory
  org.apache.commons.dbcp.BasicDataSourceFactory
driverClassName
  oracle.jdbc.driver.OracleDriver
url
  jdbc:oracle:[EMAIL PROTECTED]:1521:XXX
usernamescott
passwordj
maxActive20
maxIdle10
maxWait1
removeAbandonedtrue
removeAbandonedTimeout60
logAbandonedtrue
  

  
  

  mail.smtp.host
  localhost

  
  


  

File /web/WEB-INF/web.xml


  http://java.sun.com/dtd/web-app_2_3.dtd";>
  
Oracle Database Connection

  Pool
  jdbc/sged
  javax.sql.DataSource
  Container


  index.html
  index.jsp
  index.htm

  


Method of the class java that makes the connection test

public String obtem_dados()
{
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
resultado = new StringBuffer();
try
{
Context initContext = new InitialContext();
Context envContext = 
(Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/sged");
conn = ds.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery("SELECT COUNT(*) FROM V$SESSION");
if (rset.next())
{
resultado.append("Número de Conexões -> ");
resultado.append(rset.getString(1));
resultado.append("");
}
}
catch (java.lang.Exception e)
{
resultado.append(e.getMessage());
resultado.append("");
}
finally
{
if (conn != null)
{
try
{
conn.close();
}
catch (java.lang.Exception ex)
{
resultado.append(ex.getMessage());
resultado.append("");
}
}
}
return ((resultado.toString()));
}

Ao executar o método anterior, recebo a seguinte mensagem de erro:

Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for connect URL 
'jdbc:oracle:[EMAIL PROTECTED]:1521:GED'

Alguém tem alguma idéia do que pode estar acontecendo?

Excuse me for the gigantic message.
I thank in advance.
Sebastião Carlos Santos
Oracle Database Administrator
Universidade Federal de Uberlândia - UFU
Gratificação de Estímulo à Docência - GED



JNDI & TOMCAT (4.0.1)

2002-01-25 Thread Reinhard Ruiner

hello world,

i have written my own REALM - class for authentication. authentication - 
verfication should be done by an EnterpriseJavaBean running on JONAS 
ApplicationServer .

Within a method in my realm i set the environement for initial context as 
specified by JONAS:

Hashtable jndiProps = new Hashtable();
jndiProps.put("java.naming.factory.initial","com.sun.jndi.rmi.registry.RegistryContextFactory");
jndiProps.put("java.naming.provider.url", "rmi://localhost:10991");
jndiProps.put("java.naming.factory.url.pkgs", "org.objectweb.jonas.naming");
initialContext = new InitialContext(jndiProps); 


When I try to access a protected jsp i get following Exception

javax.naming.NoInitialContextException: Cannot instantiate 
class:com.sun.jndi.rmi.registry.RegistryContextFactory.  Root exception is 
java.lang.ClassCastException: com.sun.jndi.rmi.registry.RegistryContextFactory
at 
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)
at 
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)
at javax.naming.InitialContext.init(InitialContext.java:222)
at javax.naming.InitialContext.(InitialContext.java:198)
at 
client.daveraggett.login.LoginCatalinaRealm.getConfiguration(LoginCatalinaRealm.java:84)
at 
client.daveraggett.login.LoginCatalinaRealm.authenticate(LoginCatalinaRealm.java:50)
at 
org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:263)
at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:459)
at 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at 
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at 
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at 
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at 
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at 
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at 
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Thread.java:484)

--
To unsubscribe:   
For additional commands: 
Troubles with the list: 




JNDI / Tomcat Security Policy

2001-04-17 Thread eric chacon

Folks,

I am trying to deploy a PoolMan DataSource with JNDI, accessible from 
Tomcat.

I'm running Tomcat 3.2.1, Linux, Postgresql 7.0.?, and Apache (using 
mod_jk.so).

I seem to be having trouble with my security policies--

Poolman 1.4.1 (the most recent version I could make work--2.0 was a crashing 
failure) comes with a DeployDataSource tool that is used to attach a 
DataSource to a JNDI server.

It is run with the command line

java -Djava.security.policy=poolman.policy DeployDataSource userdb

This policy is very simple:

grant {
permission java.security.AllPermission;
};

If I understand this correctly, this should give ANY codeBase access to 
whatever is run in this process (basically, everything).

However...

When I try to run from my servlet, I get an AccessControl Exception (stack 
dump attached to the bottom of this email).

1) Has ANYBODY gotten this working? I can make Poolman work with standard 
datasource stuff (the test servlet works fine, reads my database, etc.)

2) Has anyone used JNDI for other things along with PoolMan? Is it standard 
practice to deploy resources (such as Data Sources) to JNDI servers from 
external (non-Tomcat) applications, and then have them be read by Tomcat (I 
would assume this is standard--I would assume this is what JNDI is for...)

3) Am I wrong about my understanding of the way Policies work?

Interesting Note: This may help--after an attempt to run the code that 
causes this exception, Tomcat stops working has has to be bounced.  
Basically, ANY attempt to play with tomcat (to reload a previously loaded 
JSP, for example) results in an access control error...

Interesting... in the ancient curse sense of the word ;)

Thanks,

E.

Failed to get datasource: dataSourceName = 
e=java.security.AccessControlExceptio
n: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
java.security.AccessControlException: access denied 
(java.net.SocketPermission 1
27.0.0.1:1099 connect,resolve)
at 
java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:272)
at 
java.security.AccessController.checkPermission(AccessController.java:
399)
at 
java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1044)
at java.net.Socket.(Socket.java:262)
at java.net.Socket.(Socket.java:100)
at 
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
SocketFactory.java:25)
at 
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
SocketFactory.java:120)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
at 
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190
)
at 
sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at 
com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java
:91)
at 
com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java
:101)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at org.eric.cserve.db.DSSingleton.initialize(DSSingleton.java:91)
at org.eric.cserve.db.DSSingleton.getDataSource(DSSingleton.java:43)
at org.eric.cserve.db.UserDB.executeSQL(UserDB.java:14)
at 
org.eric.mysite.authenticate.Authenticate.isAuthenticated(Authenticat
e.java:17)
at 
org.eric.mysite.authenticate.AuthenticateServlet.doService(Authentica
teServlet.java:33)
at 
org.eric.mysite.authenticate.AuthenticateServlet.doPost(AuthenticateS
ervlet.java:14)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at 
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:4
04)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at 
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372
)
at 
org.apache.tomcat.core.ContextManager.internalService(ContextManager.
java:797)
at 
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743
)
at 
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processCon
nection(Ajp12ConnectionHandler.java:166)
at 
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:
416)
at 
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
:498)
at java.lang.Thread.run(Thread.java:484)
Could not find 'poolman.props' -- now attempting to read deprecated file 
name 'p
ool.props'... failed.

java.sql.SQLException:
ERROR: Unable to find and read a valid PoolMan properties file. Please 
ensure th
at 'poolman.props' is in a directory that is in your CLASSPATH.

at com.codestudio.sql.PoolMan.connect(PoolMan.java