db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Hill <RH...@classmates.com>
Subject How to configure a DataSourceFactory?
Date Thu, 16 Oct 2003 20:15:52 GMT
How do you properly configure a DataSourceFactory for a given database? What
properties need to be modified?

Thanks,
Richard

-----------------------------------------------------
I'm trying to initialize the torque's connection pool and run an example
using torque3.0.2. When I try to save the Team data object I get a
NullPointerException trying to connect to my database pitcher. I noticed
when I tried to create the database using the "ant -f build-torque
create-db" it tried to create a database with a name in all caps. I
specified torque.project = pitchers in the build.properties files, but
torque contiues to try to connect to PITCHERS. Is there a case sensitivity
issue? 

 java.lang.NullPointerException: There was no DataSourceFactory configured
for the connection PITCHERS
        at org.apache.torque.Torque.getConnection(Torque.java:938)
        at
org.apache.torque.util.Transaction.beginOptional(Transaction.java:113)
        at org.apache.torque.util.Transaction.begin(Transaction.java:97)
        at pitchers.torque.BaseTeam.save(BaseTeam.java:1033)
        at pitchers.torque.BaseTeam.save(BaseTeam.java:1014)
        at pitchers.PitcherStats.main(PitcherStats.java:40)

-----------------------------------------------------
    PitcherStats.java excerpt:
-----------------------------------------------------

  public static void main(String args[]) {
    if (args.length == 0) {
      System.out.println
             ("Usage: pitcher [add|init|game|era|eravs|clear]");
      return;
    }

    String command = args[0];

    try {
 
Torque.init("C:/myDev/torque3.0.2_pitcher_example/bin/classes/Torque.propert
ies");
      if (command.equals("init")) {
        for (int i = 0; i < teamnames.length; i++) {
          Team t = new Team();
          t.setTeamId((i + 1));
          t.setTeamName(teamnames[i]);
          t.save(); //Line 40
        }
      }

-----------------------------------------------------
    build.properties excerpt:
-----------------------------------------------------
torque.project = pitchers
torque.database.createUrl = jdbc:mysql://rhill.corp.com:3306/pitchers
torque.database.buildUrl = jdbc:mysql://rhill.corp.com:3306/pitchers
torque.database.url = jdbc:mysql://rhill.corp.com:3306/pitchers

-----------------------------------------------------
    Torque.properties excerpt:
-----------------------------------------------------
torque.database.default=pitchers
torque.database.pitchers.adapter=mysql

## Using torque's old pool
torque.dsfactory.pitchers.factory=org.apache.torque.dsfactory.TorqueDataSour
ceFactory

---------------------------------------------------
    torque.log
---------------------------------------------------
2003-10-15 16:05:10,461 [main] INFO  org.apache.torque.Torque - Logging has
been configured by Torque.
2003-10-15 16:05:10,461 [main] DEBUG org.apache.torque.Torque - Starting
initAdapters
2003-10-15 16:05:10,521 [main] DEBUG org.apache.torque.Torque - Starting
initDSF
2003-10-15 16:05:10,521 [main] DEBUG org.apache.torque.Torque - handle:
pitchers DataSourceFactory:
org.apache.torque.dsfactory.TorqueDataSourceFactory
2003-10-15 16:05:10,561 [main] DEBUG
org.apache.torque.dsfactory.TorqueDataSourceFactory - Starting initCPDS
2003-10-15 16:05:10,581 [main] DEBUG
org.apache.torque.dsfactory.TorqueDataSourceFactory - Setting datasource
property: driver
2003-10-15 16:05:10,812 [main] DEBUG
org.apache.torque.dsfactory.TorqueDataSourceFactory - Setting datasource
property: url
2003-10-15 16:05:10,822 [main] DEBUG
org.apache.torque.dsfactory.TorqueDataSourceFactory - Setting datasource
property: user
2003-10-15 16:05:10,822 [main] DEBUG
org.apache.torque.dsfactory.TorqueDataSourceFactory - Setting datasource
property: password
2003-10-15 16:05:10,822 [main] DEBUG
org.apache.torque.dsfactory.TorqueDataSourceFactory - Starting
initTorqueClassic
2003-10-15 16:05:10,862 [main] DEBUG
org.apache.torque.dsfactory.TorqueDataSourceFactory - Setting datasource
property: defaultMaxConnections
2003-10-15 16:05:10,882 [main] DEBUG
org.apache.torque.dsfactory.TorqueDataSourceFactory - Setting datasource
property: maxExpiryTime
2003-10-15 16:05:10,882 [main] DEBUG
org.apache.torque.dsfactory.TorqueDataSourceFactory - Setting datasource
property: connectionWaitTimeout
2003-10-15 16:05:10,882 [main] DEBUG org.apache.torque.Torque - Adding a
dummy entry for default, mapped onto pitchers
2003-10-15 16:05:11,172 [main] WARN  org.apache.torque.oid.IDBroker -
IDBroker is being used with db 'PITCHERS', 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.
2003-10-15 16:05:11,322 [Thread-0] DEBUG org.apache.torque.oid.IDBroker -
IDBroker thread was started.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message