db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "eCommerce Software Solns. Inc." <vinayso...@rogers.com>
Subject JNDI Problems
Date Fri, 16 May 2003 02:12:54 GMT
Hi,

I want to run a standalone test case using JNDI.

I have the following (shown below) in my torque.properties and I am getting
the error message:

Cannot connect to MySQL server on localhost:1306. Is there a MySQL server
running on the machine/port
I am provoding the URL via:

torque.dsfactory.DBAMSV1.datasource.url = jdbc:mysql://Vin:3306/DBAMSV1

but it is somehow pointing to localhost:1306

Looks like it is not even loading the properties.

Another question is that how does it bind the context. Using straight JDBC,
I bind with file system provider. Is binding supposed to be automatic here
as there is no distinct step?

Does Torque generated layer work with JBoss successfully (my next step)?

I have already spent 2 days figuring out how JNDI could work. I have tried
the configurations provided with the download and I am convinced that those
configurations are not working (class cast exceptions etc). The config below
is leads to the debug provided below the properties. I am on the latest
Torque 3.1-alpha1 Can some one help please.

Thanks,

Vinay

#======================properties=========================
torque.applicationRoot = .


log4j.category.org.apache.torque = ALL, org.apache.torque
log4j.appender.org.apache.torque = org.apache.log4j.FileAppender
log4j.appender.org.apache.torque.file =
${torque.applicationRoot}/logs/torque.log
log4j.appender.org.apache.torque.layout = org.apache.log4j.PatternLayout
log4j.appender.org.apache.torque.layout.conversionPattern = %d [%t] %-5p
%c - %m%n
log4j.appender.org.apache.torque.append = false

torque.database.default=DBAMSV1
torque.database.default.adapter=mysql

torque.dsfactory.DBAMSV1.factory=org.apache.torque.dsfactory.JndiDataSourceF
actory

torque.dsfactory.DBAMSV1.datasource.classname=com.mysql.jdbc.jdbc2.optional.
MysqlDataSource
torque.dsfactory.DBAMSV1.factory=org.apache.torque.dsfactory.JndiDataSourceF
actory
torque.dsfactory.DBAMSV1.jndi.java.naming.factory.initial =
org.apache.naming.java.javaURLContextFactory
torque.dsfactory.DBAMSV1.jndi.java.naming.factory.url.pkgs =
org.apache.naming
torque.dsfactory.DBAMSV1.jndi.path=jdbc/AMSDB_MY_LOCAL
torque.dsfactory.DBAMSV1.datasource.url = jdbc:mysql://Vin:3306/DBAMSV1
torque.dsfactory.DBAMSV1.datasource.user = scott
torque.dsfactory.DBAMSV1.datasource.password = tiger
#======================properties end=========================

#======================System.out=========================
180 [main] DEBUG dsfactory.AbstractDataSourceFactory -
setSimpleProperty(com.mysql.jdbc.jdbc2.optional.MysqlDataSource@f73c1, url,
jdbc:mysql://Vin:3306/DBAMSV1)

180 [main] DEBUG dsfactory.JndiDataSourceFactory - Setting datasource
property: user

180 [main] DEBUG dsfactory.AbstractDataSourceFactory -
setSimpleProperty(com.mysql.jdbc.jdbc2.optional.MysqlDataSource@f73c1, user,
scott)

180 [main] DEBUG dsfactory.JndiDataSourceFactory - Setting datasource
property: password

180 [main] DEBUG dsfactory.AbstractDataSourceFactory -
setSimpleProperty(com.mysql.jdbc.jdbc2.optional.MysqlDataSource@f73c1,
password, tiger)

180 [main] DEBUG dsfactory.JndiDataSourceFactory -
InitialContext -------------------------------

190 [main] DEBUG dsfactory.JndiDataSourceFactory - Environment properties:2

190 [main] DEBUG dsfactory.JndiDataSourceFactory -
java.naming.factory.initial: org.apache.naming.java.javaURLContextFactory

190 [main] DEBUG dsfactory.JndiDataSourceFactory -
java.naming.factory.url.pkgs: org.apache.naming

190 [main] DEBUG
dsfactory.JndiDataSourceFactory - ------------------------------------------
----

200 [main] DEBUG dsfactory.JndiDataSourceFactory - Added sub context: jdbc

200 [main] DEBUG torque.Torque - Adding a dummy entry for default, mapped
onto DBAMSV1

310 [Thread-0] DEBUG oid.IDBroker - IDBroker thread was started.

1262 [main] WARN oid.IDBroker - IDBroker is being used with db 'DBAMSV1',
which does not support transactions. IDBroker attempts to use transactions
to limit the possibility of duplicate key generation. Without transactions,
duplicate key generation is possible if multiple JVMs are used or other
means are used to write to the database.

2263 [main] ERROR util.Transaction - Connection object was null. This could
be due to a misconfiguration of the DataSourceFactory. Check the logs and
Torque.properties to better determine the cause.

java.sql.SQLException: Cannot connect to MySQL server on localhost:1306. Is
there a MySQL server running on the machine/port you are trying to connect
to? (java.net.ConnectException)

at com.mysql.jdbc.Connection.connectionInit(Unknown Source)

at com.mysql.jdbc.jdbc2.Connection.connectionInit(Unknown Source)

at com.mysql.jdbc.Driver.connect(Unknown Source)

at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(Unknown
Source)

at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(Unknown
Source)

at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(Unknown
Source)

at org.apache.torque.Torque.getConnection(Torque.java:890)

at org.apache.torque.util.Transaction.beginOptional(Transaction.java:114)

at org.apache.torque.util.Transaction.begin(Transaction.java:97)

at org.rssbc.ams.dal.objects.BaseSevadar.save(BaseSevadar.java:945)

at test.Bookstore.main(Bookstore.java:43)

rethrown as org.apache.torque.TorqueException: Cannot connect to MySQL
server on localhost:1306. Is there a MySQL server running on the
machine/port you are trying to connect to? (java.net.ConnectException)

at org.apache.torque.Torque.getConnection(Torque.java:902)

at org.apache.torque.util.Transaction.beginOptional(Transaction.java:114)

at org.apache.torque.util.Transaction.begin(Transaction.java:97)

at org.rssbc.ams.dal.objects.BaseSevadar.save(BaseSevadar.java:945)

at test.Bookstore.main(Bookstore.java:43)

====================================Bookstore.java =================

public class Bookstore

{

public static void main(String[] args)

{

try

{

/*

* Initializing Torque

*/

Torque.init("Torque2.properties");

/*

* Creating new objects. These will be inserted

* into your database automatically when the

* save method is called.

*/



Sevadar name = new Sevadar();


name.setFirstname("No Name");

name.setIdnum(1);

name.save("DBAMSV1");





}

catch (Exception e)

{

e.printStackTrace();

}

}

}



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message