Also - if you want to provide jdbc connectors to any or all of your webapps, put the connectors in the common/lib folder.
Hope that helps a little... Brian Brewer
Kawthar Bt M Sulaiman wrote:
aaaahhhh..... I put my classes under
%CATALINA_HOME%\webapps\ROOT\WEB-INF\classes\com\maxis\test\TestConnection.class
I have my tomcat up and running when I ran java
com.maxis.test.TestConnection.
Isn't this "class within Tomcat"? How do I run my application without
depending
on servlet/jsp?
Thanks, --Kawthar
Kawthar,[EMAIL PROTECTED] 25/03/2004 04:04:51 PM >>>
From what I understand the context is not available from outsideTomcat. If you are running this from an IDE or command line you are in a separate JVM form Tomcat. You have to be trying your code from a servlet, jsp or class within Tomcat to use the context.
Doug
----- Original Message ----- From: "Kawthar Bt M Sulaiman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 25, 2004 2:58 AM
Subject: Re: JDBC/mySQL problem.
Doug,server.xml
I created a test stand-alone application: TestConnection.java Inside theis class, it has public static void main(Strig[] args) { DatabaseOperation op = DatabaseOperation.newInstance(); op.selectOperation(....) ... }
When DatabaseOperation is initialized, that's when it get the
connection.
The line where I get new InitialContext() is when the error was
thrown.
So I'm not sure when actually the "driverClassName" inside
connectionis being called.
Thanks, --Kawthar
Kawthar,[EMAIL PROTECTED] 25/03/2004 03:33:40 PM >>>
Please clarify what you mean by "inside the main()".
Doug
----- Original Message ----- From: "Kawthar Bt M Sulaiman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 24, 2004 9:37 PM
Subject: RE: JDBC/mySQL problem.
Hi folks,
Sorry to bring back this issue.... I still cannot make my
ispooling to work... arrrgghh...
I got the configuration as stated in email below.. except my path
theempty ("").
I created a simple java test and inside the main(), I just call
applicationinDatabaseOperation class and it should initialize all the connections. The error I got as follows:
javax.naming.NoInitialContextException: Need to specify class name
environment
or system property, or as an applet parameter, or in an
Source)resource file:
java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown
Isn'tat javax.naming.InitialContext.lookup(Unknown Source) at com.maxis.app.DatabaseOperation.initialConnection
I've specified the <name>driverClassName</name> in server.xml.
this valueresource
loaded in my environment/system property? What is application
file?
Any ideas/suggestions? BTW, if I use Class.forName("com.mysql.jdbc.Driver"); DriverManager.getConnection("....") coding, that works fine.. I can connect to database.
Thanks, --Kawthar
[EMAIL PROTECTED] 19/03/2004 10:12:17 PM >>>
If I could see the error it would help but I don't think your datasource is getting loaded correctly into JNDI. The full name of the jar in common/lib works fine. Here is the context.xml I used based on the HOW_TO and it works great. If this file doesn't work, it is most likely a location or alternate error.
<Context path="/DBTest" docBase="DBTest" debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_DBTest_log." suffix=".txt" timestamp="true"/>
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
still</parameter> <parameter> <name>maxActive</name> <value>100</value> </parameter> <parameter> <name>maxIdle</name> <value>30</value> </parameter> <parameter> <name>maxWait</name> <value>10000</value> </parameter> <parameter> <name>username</name> <value>javauser</value> </parameter> <parameter> <name>password</name> <value>javadude</value> </parameter> <parameter> <name>driverClassName</name> <value>com.mysql.jdbc.Driver</value> <parameter> <name>url</name>
<value>jdbc:mysql://localhost/javatest?autoReconnect=true</value> </parameter> </ResourceParams> </Context>
-----Original Message-----
From: Kawthar Bt M Sulaiman [mailto:[EMAIL PROTECTED] Sent: Thursday, March 18, 2004 6:52 PM
To: [EMAIL PROTECTED] Subject: Re: JDBC/mySQL problem.
Yes, I have the latest connector inside my /common/lib. mysql-connector-java-3.0.11-stable-bin.jar
I even tried naming this without the word "stable" in it, and
parameters={url=jdbc:mysql://localhost:3306/ecpa?autoReconnect=true,not working.
In my log file, I can see the following: Creating JNDI naming context
Resource parameters for jdbc/mySQLDatabase = ResourceParams[name=jdbc/mySQLDatabase,
that:serverName=localhost, maxActive=100,factory=org.apache.commons.dbcp.BasicDataSourceFactory,
drvierClassName=com.mysql.jdbc.Driver, removeAbandoned=true,
username=root,
password=xxx}]factoryClassLocation=null,
ResourceRef[className=javax.sql.DataSource,
factoryClassName=org.apache.naming.factory.ResourceFactory,.....<same
info as above>]
Do you see anything strage? The factoryClassLocation is NULL.. is this a problem?
Thanks, --Kawthar
hi my aplication use mysql and the conection config looks like[EMAIL PROTECTED] 18/03/2004 09:36:37 PM >>>
<[EMAIL PROTECTED]>(piece)under
<DRIVER>com.mysql.jdbc.Driver</DRIVER>
<URL>jdbc:mysql://localhost:3306/database</URL>
<LOGIN>root</LOGIN>
<PASSWORD></PASSWORD>you dont need password wen your in local
context
+did you downloader the latest connecter
mysql-connector-java-3.0.10-stable-bin from mysql and copied it
your comon /lib +/lib of your aplication ? here everyting works fine and im on tomcat 4.0
----- Original Message ----- From: "Parsons Technical Services"
usernameapplyingTo: "Tomcat Users List" <[EMAIL PROTECTED]> Sent: Thursday, March 18, 2004 12:29 AM Subject: Re: JDBC/mySQL problem.
Kawthar,liked it
As for Steve's concerns:
It is the same one. The short story: Mark Mathews wrote it MySQL
and adopted it and him. So it went from org.gjt.mm to com.mysql.Both
names
will work fine but to be up to date use the com.mysql.common.
As for server.xml having only one is fine, and on TC4 this is
If
you
move to TC5 then you can have multiple files with each part
todon't
only
the app that it is included with. For now don't worry about it.problems
If your application is running OK as ROOT other than the DBCP
then
you are fine. It is that most people set up a new context and
messyou're
with the ROOT at first. But again if the rest of the app runs
fine.
Now for fifty questions: You are rebooting after changes? It has bitten me several times.
Have you done a manual connection? Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection( "jdbc:mysql://localhost:3306/ecpa", "youruser", "yourpassword");
If the manual connection fails then:
Can you access the database directly and log on using the
youand
password that is in the context?
Can you open a prompt and ping localhost? I have seen it fail.
If so use the IP of your machine if you can ping it otherwise
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>havegain
other
issues.
Are you running a firewall on the machine?
What OS are you on?
What are the rights for the user in the database, can the user
access
from localhost?<[EMAIL PROTECTED]>
Doug
----- Original Message ----- From: "Kawthar Bt M Sulaiman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 17, 2004 11:46 PM
Subject: Re: JDBC/mySQL problem.
Followed your suggestion, but still not working.
Thnx, --Kawthar
Kawthar,[EMAIL PROTECTED] 18/03/2004 12:18:00 PM >>>
Change:
<Resource auth="Container" description="JDBC Connection to MySQL v4.0.18" name="mySQLDatabase" scope="Shareable" type="javax.sql.DataSource"/>
<Resource name="jdbc/mySQLDatabase" auth="Container" type="javax.sql.DataSource"/>
To:
<Resource auth="Container" description="JDBC Connection to MySQL v4.0.18" name="jdbc/mySQLDatabase" scope="Shareable" type="javax.sql.DataSource"/>
Should work either way, mine did, just cleaner and proper. Note name is changed in second entry, added jdbc/ .
Doug
----- Original Message ----- From: "Parsons Technical Services"
reloadable="true">To: "Tomcat Users List" <[EMAIL PROTECTED]> Sent: Wednesday, March 17, 2004 11:02 PM Subject: Re: JDBC/mySQL problem.
Kawthar,
Try this context in place of yours.
<Context path="/db" docBase ="ROOT" debug="9"
<Resource auth="Container" description="JDBC Connection to MySQL v4.0.18" name="mySQLDatabase" scope="Shareable" type="javax.sql.DataSource"/>
<Resource name="jdbc/mySQLDatabase" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/mySQLDatabase"> <parameter> <name>factory</name>
---------------------------------------------------------------------<value>jdbc:mysql://localhost:3306/ecpa?autoReconnect=true</value></parameter> <parameter> <name>username</name> <value>xxxx</value> </parameter> <parameter> <name>password</name> <value>xxxx</value> </parameter> <parameter> <name>maxActive</name> <value>100</value> </parameter> <parameter> <name>maxIdle</name> <value>5</value> </parameter> <parameter> <name>maxWait</name> <value>10000</value> </parameter>
<parameter> <name>driverClassName</name> <value>org.gjt.mm.mysql.Driver</value> </parameter> <parameter> <name>url</name>
className="org.apache.catalina.logger.FileLogger"</parameter> </ResourceParams>
<Logger
eachprefix="DBlog." suffix=".txt" timestamp="true"/> </Context>
Don't forget to close the statement and the result set.
I do mine in a finally block along with the conn.close() and
one
is
wrapped in a try / catch.server.xml.
Make sure to restart Tomcat after you make changes to the
Doug
---------------------------------------------------------------------[EMAIL PROTECTED]To unsubscribe, e-mail:
[EMAIL PROTECTED]For additional commands, e-mail:
---------------------------------------------------------------------[EMAIL PROTECTED]To unsubscribe, e-mail:
[EMAIL PROTECTED]For additional commands, e-mail:
---------------------------------------------------------------------[EMAIL PROTECTED]To unsubscribe, e-mail:
[EMAIL PROTECTED]For additional commands, e-mail:
[EMAIL PROTECTED]To unsubscribe, e-mail:
---------------------------------------------------------------------[EMAIL PROTECTED]For additional commands, e-mail:
To unsubscribe, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]For additional commands, e-mail:
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]For additional commands, e-mail:
indicatedConfidential information may be contained in this e-mail and anyfiles
transmitted with it ('Message'). If you are not the addressee
inprinting
this Message (or responsible for delivery of this Message to such
person),
you are hereby notified that any dissemination, distribution,
orIn
copying of this Message or any part thereof is strictly prohibited.
such---------------------------------------------------------------------
a case, you should delete this Message immediately and advise the
sender by
return e-mail. Opinions, conclusions and other information in this
Message
that do not relate to the official business of Maxis shall be
understood as
neither given nor endorsed by Maxis.
To unsubscribe, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]For additional commands, e-mail:
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Confidential information may be contained in this e-mail and anyfiles
transmitted with it ('Message'). If you are not the addressee indicated
in
this Message (or responsible for delivery of this Message to such
person),
you are hereby notified that any dissemination, distribution, printing
or
copying of this Message or any part thereof is strictly prohibited. In
such
a case, you should delete this Message immediately and advise the
sender by
return e-mail. Opinions, conclusions and other information in this
Message
that do not relate to the official business of Maxis shall be
understood as
neither given nor endorsed by Maxis.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Confidential information may be contained in this e-mail and any files transmitted with it ('Message'). If you are not the addressee indicated in this Message (or responsible for delivery of this Message to such person), you are hereby notified that any dissemination, distribution, printing or copying of this Message or any part thereof is strictly prohibited. In such a case, you should delete this Message immediately and advise the sender by return e-mail. Opinions, conclusions and other information in this Message that do not relate to the official business of Maxis shall be understood as neither given nor endorsed by Maxis.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]