You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Stefan Krause <st...@minet.uni-jena.de> on 2002/01/19 19:26:26 UTC

torque: problem inserting data into database table

Hi,

I use torque in the stand-alone version and I try to insert data into a
database table.
I use mysql. The peer classes are created. I compiled my test class
"DBTest" succesfully.
My database table to insert exists and is called "Contributor".
Here is the code:

package org.openscience.nmrshiftdb;

public class DBTest
{
	public static void main(String args[])
	{
		Contributor con = new Contributor();
		con.setFirstName("name");
		con.setLastName("name");
		con.setZipCode(1234);
		try
		{
			ContributorPeer.doInsert(con);
			con.save();
		}
		catch (Exception exc)
		{
		}
	}
}

When I do run I get the following exception:

run:
     [java] Exception in thread "main"
java.lang.ExceptionInInitializerError: java.lang.NullPointerException
     [java]	at
org.apache.torque.util.BasePeer.getMapBuilder(BasePeer.java:1922)
     [java]	at
org.opensience.nmrshiftdb.BaseContributorPeer.<clinit>(BaseContributorPeer.java:29)
     [java]	at org.opensience.nmrshiftdb.DBTest.main(DBTest.java:36)
     [java] Java Result: 1

Is it because it can't find the BasePeer class?
I would be grateful for an advice.
Thanks in advance.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: torque: problem inserting data into database table

Posted by Fabian Moerchen <fa...@mybytes.de>.
hi,

i had a similar problem. but i used an old version of torque, i got it
to work with the dev version now. see other post for steps.

bye
fabian

On Sat, 2002-01-19 at 19:26, Stefan Krause wrote:
> Hi,
> 
> I use torque in the stand-alone version and I try to insert data into a
> database table.
> I use mysql. The peer classes are created. I compiled my test class
> "DBTest" succesfully.
> My database table to insert exists and is called "Contributor".
> Here is the code:
> 
> package org.openscience.nmrshiftdb;
> 
> public class DBTest
> {
> 	public static void main(String args[])
> 	{
> 		Contributor con = new Contributor();
> 		con.setFirstName("name");
> 		con.setLastName("name");
> 		con.setZipCode(1234);
> 		try
> 		{
> 			ContributorPeer.doInsert(con);
> 			con.save();
> 		}
> 		catch (Exception exc)
> 		{
> 		}
> 	}
> }
> 
> When I do run I get the following exception:
> 
> run:
>      [java] Exception in thread "main"
> java.lang.ExceptionInInitializerError: java.lang.NullPointerException
>      [java]	at
> org.apache.torque.util.BasePeer.getMapBuilder(BasePeer.java:1922)
>      [java]	at
> org.opensience.nmrshiftdb.BaseContributorPeer.<clinit>(BaseContributorPeer.java:29)
>      [java]	at org.opensience.nmrshiftdb.DBTest.main(DBTest.java:36)
>      [java] Java Result: 1
> 
> Is it because it can't find the BasePeer class?
> I would be grateful for an advice.
> Thanks in advance.
> 
> Stefan
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: torque: problem inserting data into database table

Posted by Heiko Braun <he...@hlan.org>.
Hi,

i dont have a concrete answer, but i was 
wondering about your code. Isn't it redundent to 
first call doInsert() manually and afterwards call save() 
(which then starts the transaction) ?

Heiko

On Sat, 19 Jan 2002 19:26:26 +0100
Stefan Krause <st...@minet.uni-jena.de> wrote:

  | Hi,
  | 
  | I use torque in the stand-alone version and I try to insert data into a
  | database table.
  | I use mysql. The peer classes are created. I compiled my test class
  | "DBTest" succesfully.
  | My database table to insert exists and is called "Contributor".
  | Here is the code:
  | 
  | package org.openscience.nmrshiftdb;
  | 
  | public class DBTest
  | {
  | 	public static void main(String args[])
  | 	{
  | 		Contributor con = new Contributor();
  | 		con.setFirstName("name");
  | 		con.setLastName("name");
  | 		con.setZipCode(1234);
  | 		try
  | 		{
  | 			ContributorPeer.doInsert(con);
  | 			con.save();
  | 		}
  | 		catch (Exception exc)
  | 		{
  | 		}
  | 	}
  | }
  | 
  | When I do run I get the following exception:
  | 
  | run:
  |      [java] Exception in thread "main"
  | java.lang.ExceptionInInitializerError: java.lang.NullPointerException
  |      [java]	at
  | org.apache.torque.util.BasePeer.getMapBuilder(BasePeer.java:1922)
  |      [java]	at
  | org.opensience.nmrshiftdb.BaseContributorPeer.<clinit>(BaseContributorPeer.java:29)
  |      [java]	at org.opensience.nmrshiftdb.DBTest.main(DBTest.java:36)
  |      [java] Java Result: 1
  | 
  | Is it because it can't find the BasePeer class?
  | I would be grateful for an advice.
  | Thanks in advance.
  | 
  | Stefan
  | 
  | --
  | To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
  | For additional commands, e-mail: <ma...@jakarta.apache.org>
  | 


-- 
' 
 Heiko Braun <he...@hlan.org>
 Software Development

 Java, Open Source
 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Torque: Joining tables What am I doing wrong ?

Posted by Emmanuel Bardet <em...@bardet.org>.
But of course. Silly me. Thanks and sorry.

> -----Original Message-----
> From: Wolfgang Klier [mailto:wolfi@nautilus.noreply.org]
> Sent: mercredi 30 janvier 2002 17:30
> To: Turbine Users List
> Subject: Re: Torque: Joining tables What am I doing wrong ?
> 
> 
> Hi
> On Wed, Jan 30, 2002 at 03:46:00PM -0000, Emmanuel Bardet wrote:
> > critUnit.addJoin ( TarMenuFoodPeer.FOOD_ID,
> > tarMenuFoodLanguageName.getFoodId().toString() );
> 
> This is no JOIN, but a constraint.
> 
> Wolfgang
> 
> --
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
> 
> 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Torque: Joining tables What am I doing wrong ?

Posted by Wolfgang Klier <wo...@nautilus.noreply.org>.
Hi
On Wed, Jan 30, 2002 at 03:46:00PM -0000, Emmanuel Bardet wrote:
> critUnit.addJoin ( TarMenuFoodPeer.FOOD_ID,
> tarMenuFoodLanguageName.getFoodId().toString() );

This is no JOIN, but a constraint.

Wolfgang

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: torque: rollback on mysql

Posted by Pete Kazmier <pe...@kazmier.com>.
Stefan,

It would be helpful if you included your schema, build.propertiers, and
run-time properties as well.  Rather than post these to the list, feel
free to send these to me directly and I'll take a look at them for you,
and post the results back to the list.  

In addition, you may want to read the tutorial that I am putting
together.  I'm sure if you followed that you'd find your problem  The
URL to the work-in-progress is:

http://www.kazmier.com/~kaz/torque/tutorial.html

Thanks,
Pete

On Wed, Jan 30, 2002 at 03:29:49PM +0100, Stefan Krause wrote:
> Hi,
> 
> I have a problem with storing data in the mysql database. When I 
> call the save() method I get an error in the torque.log file which says
> my database do not allow this operation. But rollback is allowed by
> mysql.
> Can someone give me an advice?
> 
> this is my simple test-class:
> 
> package org.openscience.nmrshiftdb;
> 
> import org.apache.torque.Torque;
> import org.apache.torque.util.Criteria;
> import org.openscience.nmrshiftdb.*;
> import java.util.*;
> 
> public class DBTest
> {	
> 	public static void main(String[] args)
> 	{
> 		try
> 		{
> 			Torque.init("/home/stefan/dev/nmrshiftdb/schema/Torque.properties");
> 			Contributor con = new Contributor();
> 			con.setId("1");
> 			con.setFirstName("firstname");
> 			con.setLastName("lastname");
> 			con.save();
> 		}
> 		catch (Exception exc)
> 		{
> 		}
> 	}
> }
> 
> 
> Here is the error message i got in the torque.log file:
> 
> INFO - Logging has been configured by Torque.
> DEBUG - Using org.apache.torque.adapter.DBMM
> INFO - IDBroker thread was started.
> WARN - IDBroker is being used with db 'nmrshiftdb', 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.
> INFO - Forced id retrieval - no available vector
> DEBUG - BasePeer.doUpdate: whereClause=TABLE_NAME='CONTRIBUTOR'
> ERROR - An attempt was made to rollback a transaction but the database
> did not allow the operation to be rolled back.
> 
> Thanks.
> 
> Stefan
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Peter Kazmier                                 http://www.kazmier.com
PGP Fingerprint   4FE7 8DA3 D0B5 9CAA 69DC  7243 1855 BC2E 4B43 5654

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: torque: rollback on mysql

Posted by Erich Meier <em...@methodpark.de>.
On Wed, Jan 30, 2002 at 03:29:49PM +0100, Stefan Krause wrote:
> Hi,
> 
> I have a problem with storing data in the mysql database. When I 
> call the save() method I get an error in the torque.log file which says
> my database do not allow this operation. But rollback is allowed by
> mysql.
> Can someone give me an advice?

I assume, that you use the mm.mysql JDBC driver. It has some transaction
fixes in release 2.0.8 so you should check that your version is up-to-date.

Version 2.0.6 returned false on
	getConnection().getMetaData().supportsTransactions()
which was corrected.

Hope this helps,
Erich

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Torque: Joining tables What am I doing wrong ?

Posted by Emmanuel Bardet <em...@bardet.org>.
Hello guys,

Pretty straight forward but I can't make it work!

This code:
Criteria critUnit = new Criteria();
critUnit.addJoin( TarMenuNamePeer.NAME_ID,
TarMenuUnitLanguageNamePeer.NAME_ID );
critUnit.addJoin( TarMenuUnitLanguageNamePeer.UNIT_ID,
TarMenuFoodPeer.UNIT_ID );
critUnit.addJoin ( TarMenuFoodPeer.FOOD_ID,
tarMenuFoodLanguageName.getFoodId().toString() );
critUnit.add (TarMenuUnitLanguageNamePeer.LANGUAGE_ID, language_id);

Vector vector = TarMenuNamePeer.doSelect( critUnit );

throws an exception:
Exception:  java.lang.StringIndexOutOfBoundsException: String index out of
range: -1
Stack Trace follows:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1525)
at org.apache.turbine.om.peer.BasePeer.createQueryString(BasePeer.java:1033)
at org.apache.turbine.om.peer.BasePeer.doSelect(BasePeer.java:1131)
at
com.mctar.menu.om.BaseTarMenuNamePeer.doSelectVillageRecords(BaseTarMenuName
Peer.java:197)
at
com.mctar.menu.om.BaseTarMenuNamePeer.doSelect(BaseTarMenuNamePeer.java:167)


I don't see what I'm doing wrong here. Can anybody help ?

Thanks.

Emmanuel.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


torque: rollback on mysql

Posted by Stefan Krause <st...@minet.uni-jena.de>.
Hi,

I have a problem with storing data in the mysql database. When I 
call the save() method I get an error in the torque.log file which says
my database do not allow this operation. But rollback is allowed by
mysql.
Can someone give me an advice?

this is my simple test-class:

package org.openscience.nmrshiftdb;

import org.apache.torque.Torque;
import org.apache.torque.util.Criteria;
import org.openscience.nmrshiftdb.*;
import java.util.*;

public class DBTest
{	
	public static void main(String[] args)
	{
		try
		{
			Torque.init("/home/stefan/dev/nmrshiftdb/schema/Torque.properties");
			Contributor con = new Contributor();
			con.setId("1");
			con.setFirstName("firstname");
			con.setLastName("lastname");
			con.save();
		}
		catch (Exception exc)
		{
		}
	}
}


Here is the error message i got in the torque.log file:

INFO - Logging has been configured by Torque.
DEBUG - Using org.apache.torque.adapter.DBMM
INFO - IDBroker thread was started.
WARN - IDBroker is being used with db 'nmrshiftdb', 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.
INFO - Forced id retrieval - no available vector
DEBUG - BasePeer.doUpdate: whereClause=TABLE_NAME='CONTRIBUTOR'
ERROR - An attempt was made to rollback a transaction but the database
did not allow the operation to be rolled back.

Thanks.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: torque: problem inserting data into database table

Posted by Pete Kazmier <pe...@kazmier.com>.
Your log4j configuration is incorrect.  To get you up and running, I'd
suggest deleting all the lines that start with "log4j" from your
torque.properties file and replace them with (as the tutorial suggests):

log4j.rootCategory = DEBUG, default
log4j.appender.default = org.apache.log4j.FileAppender
log4j.appender.default.file = ./torque.log
log4j.appender.default.layout = org.apache.log4j.SimpleLayout

This is a very simple log4j configuration.  Its enough to get you going,
if you want more frills, then I'd suggest reading the log4j
documentation.  They have a very good introduction here:

http://jakarta.apache.org/log4j/docs/manual.html

Thanks,
Pete

On Mon, Jan 28, 2002 at 01:24:12PM +0100, Stefan Krause wrote:
> I followed the steps in your email to save the data in my table. I
> also checked out the tutorial. But it still doesn't work. So here are
> my files:
> 
[snip]
>
> It compiles without errors. By running I get this error message:
> 
> run:
>      [java] log4j:ERROR Could not instantiate class
> [org.apache.log4j.FileAppender,org.apache.log4j.FileAppender].
>
[snip]
>
> log4j.category.default = ALL, default
> log4j.appender.default = org.apache.log4j.FileAppender
> log4j.appender.default.file = ./torque.log
> log4j.appender.default.layout = org.apache.log4j.PatternLayout
> log4j.appender.default.layout.conversionPattern = %d [%t] %-5p %c - %m%n
> log4j.appender.default.append = false
> 
> log4j.category.org.apache.torque = ALL, org.apache.torque
> log4j.appender.org.apache.torque = org.apache.log4j.FileAppender
> log4j.appender.org.apache.torque.file = ./turbine.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
> 
> log4j.category.sql = DEBUG, sql
> log4j.appender.sql = org.apache.log4j.FileAppender
> log4j.appender.sql.file = ./sql.log
> log4j.appender.sql.layout = org.apache.log4j.PatternLayout
> log4j.appender.sql.layout.conversionPattern = %d [%t] %-5p %c - %m%n
> log4j.appender.sql.append = false
> log4j.rootCategory = DEBUG, default
> 
> log4j.appender.default = org.apache.log4j.FileAppender
> log4j.appender.default.file = ./torque.log
> log4j.appender.default.layout = org.apache.log4j.SimpleLayout
>                                                      
> log4j.rootCategory = DEBUG, default
> log4j.appender.default = org.apache.log4j.FileAppender
> log4j.appender.default.file = ./torque.log
> log4j.appender.default.layout = org.apache.log4j.SimpleLayout

-- 
Peter Kazmier                                 http://www.kazmier.com
PGP Fingerprint   4FE7 8DA3 D0B5 9CAA 69DC  7243 1855 BC2E 4B43 5654

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: torque: problem inserting data into database table

Posted by Stefan Krause <st...@minet.uni-jena.de>.
Pete Kazmier wrote:
> 
> I should be done with the tutorial in the next few days.  Hopefully that
> will answer your question.  In the meantime, the save() method
> eventually calls doInsert() or doUpdate() (depending if the object has
> been modified), so its redundant to call the doInsert() yourself.
> 
> Check out the tutorial again, I have a lot of it done, if you follow
> those configuration tasks I outlined, then you should not have a problem
> with your application.  I have been able to run my sample appliaction
> (the one that will be included in the tutorial).
> 
> If you still can't get it working, feel free to mail me your
> build.properties file, Torque.properties file, and your schema and I'd
> be happy to take a peek.
> 
> Thanks,
> Pete

I followed the steps in your email to save the data in my table. I also
checked
out the tutorial. But it still doesn't work. So here are my files:
My test class DBTest.java:

package org.openscience.nmrshiftdb;

import org.apache.torque.Torque;
import org.apache.torque.util.Criteria;
import java.util.Vector;

public class DBTest
{
	public static void main(String args[])
	{
		Contributor con = new Contributor();
		con.setFirstName("firstname");
		con.setLastName("lastname");
		try
		{
			Torque.init("/home/stefan/dev/nmrshiftdb/schema/Torque.properties");
			con.save();
		}
		catch (Exception exc)
		{
		}
	}
}

It compiles without errors. By running I get this error message:

run:
     [java] log4j:ERROR Could not instantiate class
[org.apache.log4j.FileAppender,org.apache.log4j.FileAppender].
     [java] java.lang.ClassNotFoundException:
org/apache/log4j/FileAppender,org/apache/log4j/FileAppender
     [java] 	at java.lang.Class.forName0(Native Method)
     [java] 	at java.lang.Class.forName(Class.java:120)
     [java] 	at
org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:301)
     [java] 	at
org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:116)
     [java] 	at
org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:612)
     [java] 	at
org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:595)
     [java] 	at
org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:502)
     [java] 	at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:410)
     [java] 	at
org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:341)
     [java] 	at
org.apache.torque.Torque.configureLogging(Torque.java:306)
     [java] 	at org.apache.torque.Torque.init(Torque.java:177)
     [java] 	at org.apache.torque.Torque.init(Torque.java:156)
     [java] 	at org.openscience.nmrshiftdb.DBTest.main(DBTest.java:27)
     [java] log4j:ERROR Could not instantiate appender named "default".
     [java] log4j:ERROR Could not instantiate class
[org.apache.log4j.FileAppender,org.apache.log4j.FileAppender].
     [java] java.lang.ClassNotFoundException:
org/apache/log4j/FileAppender,org/apache/log4j/FileAppender
     [java] 	at java.lang.Class.forName0(Native Method)
     [java] 	at java.lang.Class.forName(Class.java:120)
     [java] 	at
org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:301)
     [java] 	at
org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:116)
     [java] 	at
org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:612)
     [java] 	at
org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:595)
     [java] 	at
org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:522)
     [java] 	at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:412)
     [java] 	at
org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:341)
     [java] 	at
org.apache.torque.Torque.configureLogging(Torque.java:306)
     [java] 	at org.apache.torque.Torque.init(Torque.java:177)
     [java] 	at org.apache.torque.Torque.init(Torque.java:156)
     [java] 	at org.openscience.nmrshiftdb.DBTest.main(DBTest.java:27)
     [java] log4j:ERROR Could not instantiate appender named "default".



The build.properties file:

project = nmrshiftdb

database = mysql

targetPackage=org.openscience.nmrshiftdb
basePrefix=Base
addSaveMethod=true
addGetByNameMethod=true
complexObjectModel=true
addTimeStamp=true
addIntakeRetrievable=false

createDatabaseUrl = jdbc:mysql://127.0.0.1/mysql
databaseUrl = jdbc:mysql://127.0.0.1/nmrshiftdb
databaseDriver = org.gjt.mm.mysql.Driver
databaseUser = turbine
databasePassword = turbine
databaseHost = 127.0.0.1

sameJavaName=false

documentationFormat=html

templatePath = templates

SQLControlTemplate = sql/base/Control.vm
OMControlTemplate = om/Control.vm
idTableControlTemplate = sql/id-table/Control.vm
DataDTDControlTemplate = data/Control.vm
DataDumpControlTemplate = data/dump/Control.vm
DataSQLControlTemplate = sql/load/Control.vm
DocControlTemplate = doc/Control.vm

outputDirectory=src

schemaDirectory=schema




The torque.properties file:


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

log4j.category.org.apache.torque = ALL, org.apache.torque
log4j.appender.org.apache.torque = org.apache.log4j.FileAppender
log4j.appender.org.apache.torque.file = ./turbine.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

log4j.category.sql = DEBUG, sql
log4j.appender.sql = org.apache.log4j.FileAppender
log4j.appender.sql.file = ./sql.log
log4j.appender.sql.layout = org.apache.log4j.PatternLayout
log4j.appender.sql.layout.conversionPattern = %d [%t] %-5p %c - %m%n
log4j.appender.sql.append = false
log4j.rootCategory = DEBUG, default

log4j.appender.default = org.apache.log4j.FileAppender
log4j.appender.default.file = ./torque.log
log4j.appender.default.layout = org.apache.log4j.SimpleLayout
                                                     
log4j.rootCategory = DEBUG, default
log4j.appender.default = org.apache.log4j.FileAppender
log4j.appender.default.file = ./torque.log
log4j.appender.default.layout = org.apache.log4j.SimpleLayout
torque.database.default=nmrshiftdb
          
torque.earlyInit = true

torque.database.default=nmrshiftdb
torque.database.nmrshiftdb.driver = org.gjt.mm.mysql.Driver
torque.database.nmrshiftdb.url = jdbc:mysql://127.0.0.1/nmrshiftdb
torque.database.nmrshiftdb.username = turbine
torque.database.nmrshiftdb.password = turbine

torque.database.default.maxConnections=80

torque.database.default.expiryTime=3600000

torque.database.default.connectionWaitTimeout=10000

torque.database.logInterval=0

torque.database.adapter=DBOdbc, DBMM
torque.database.adapter.DBOdbc=sun.jdbc.odbc.JdbcOdbcDriver
torque.database.adapter.DBMM=
torque.database.adapter.DBMM=org.gjt.mm.mysql.Driver

torque.database.idbroker.cleverquantity=true



The nmrshiftdb-schema.xml file:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
<!DOCTYPE database SYSTEM
"http://jakarta.apache.org/turbine/dtd/database.dtd">

<database name="nmrshiftdb" defaultIdMethod="idbroker">  
  <table name="CONTRIBUTOR">
    <column name="CONTRIBUTOR_ID" required="true" primaryKey="true" 
            type="INTEGER" javaName="Id"/>
    <column name="FIRST_NAME" required="true" type="LONGVARCHAR"/>
    <column name="LAST_NAME" required="true" type="LONGVARCHAR"/>
  </table>

  <table name="CHEMICALNAME">
    <column name="CHEMICALNAME_ID" required="true" primaryKey="true" 
            type="INTEGER"/>
    <column name="NAME" required="true" type="LONGVARCHAR"/>
  </table>
</database>  


I would be grateful for an advice.
Thanks in advance.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: torque: problem inserting data into database table

Posted by Pete Kazmier <pe...@kazmier.com>.
I should be done with the tutorial in the next few days.  Hopefully that
will answer your question.  In the meantime, the save() method
eventually calls doInsert() or doUpdate() (depending if the object has
been modified), so its redundant to call the doInsert() yourself.

Check out the tutorial again, I have a lot of it done, if you follow
those configuration tasks I outlined, then you should not have a problem
with your application.  I have been able to run my sample appliaction
(the one that will be included in the tutorial).

If you still can't get it working, feel free to mail me your
build.properties file, Torque.properties file, and your schema and I'd
be happy to take a peek.

Thanks,
Pete

On Tue, Jan 22, 2002 at 02:47:01PM +0100, Stefan Krause wrote:
> Hi,
> 
> yes that's true. I tried to store the object in the way described 
> in the Peers Howto. That didn't work. So I looked in the 
> Base<TableName>Peer.java and the Base<TableName>.java files. 
> The explanation for the method doInsert() was '/**Method to do
> inserts*/'.
> save() is for 'storing the object in the database'. I just wanted to be
> sure 
> not to get the answer: take the save() method or take the doInsert()
> method. 
> 
> Thanks a lot to Pete and Fabian for the instructions and the tutorial!
> 
> Stefan
> 
> 
> 
> 
> Heiko Braun wrote:
> > 
> > Hi,
> > 
> > i dont have a concrete answer, but i was
> > wondering about your code. Isn't it redundent to
> > first call doInsert() manually and afterwards call save()
> > (which then starts the transaction) ?
> > 
> > Hope that helps,
> > 
> > Heiko
> > 
> > On Sat, 19 Jan 2002 19:26:26 +0100
> > Stefan Krause <st...@minet.uni-jena.de> wrote:
> > 
> >   | Hi,
> >   |
> >   | I use torque in the stand-alone version and I try to insert data into a
> >   | database table.
> >   | I use mysql. The peer classes are created. I compiled my test class
> >   | "DBTest" succesfully.
> >   | My database table to insert exists and is called "Contributor".
> >   | Here is the code:
> >   |
> >   | package org.openscience.nmrshiftdb;
> >   |
> >   | public class DBTest
> >   | {
> >   |     public static void main(String args[])
> >   |     {
> >   |             Contributor con = new Contributor();
> >   |             con.setFirstName("name");
> >   |             con.setLastName("name");
> >   |             con.setZipCode(1234);
> >   |             try
> >   |             {
> >   |                     ContributorPeer.doInsert(con);
> >   |                     con.save();
> >   |             }
> >   |             catch (Exception exc)
> >   |             {
> >   |             }
> >   |     }
> >   | }
> >   |
> >   | When I do run I get the following exception:
> >   |
> >   | run:
> >   |      [java] Exception in thread "main"
> >   | java.lang.ExceptionInInitializerError: java.lang.NullPointerException
> >   |      [java] at
> >   | org.apache.torque.util.BasePeer.getMapBuilder(BasePeer.java:1922)
> >   |      [java] at
> >   | org.opensience.nmrshiftdb.BaseContributorPeer.<clinit>(BaseContributorPeer.java:29)
> >   |      [java] at org.opensience.nmrshiftdb.DBTest.main(DBTest.java:36)
> >   |      [java] Java Result: 1
> >   |
> >   | Is it because it can't find the BasePeer class?
> >   | I would be grateful for an advice.
> >   | Thanks in advance.
> >   |
> >   | Stefan
> >   |
> >   | --
> >   | To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> >   | For additional commands, e-mail: <ma...@jakarta.apache.org>
> >   |
> > 
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Peter Kazmier                                 http://www.kazmier.com
PGP Fingerprint   4FE7 8DA3 D0B5 9CAA 69DC  7243 1855 BC2E 4B43 5654

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: torque: problem inserting data into database table

Posted by Stefan Krause <st...@minet.uni-jena.de>.
Hi,

yes that's true. I tried to store the object in the way described 
in the Peers Howto. That didn't work. So I looked in the 
Base<TableName>Peer.java and the Base<TableName>.java files. 
The explanation for the method doInsert() was '/**Method to do
inserts*/'.
save() is for 'storing the object in the database'. I just wanted to be
sure 
not to get the answer: take the save() method or take the doInsert()
method. 

Thanks a lot to Pete and Fabian for the instructions and the tutorial!

Stefan




Heiko Braun wrote:
> 
> Hi,
> 
> i dont have a concrete answer, but i was
> wondering about your code. Isn't it redundent to
> first call doInsert() manually and afterwards call save()
> (which then starts the transaction) ?
> 
> Hope that helps,
> 
> Heiko
> 
> On Sat, 19 Jan 2002 19:26:26 +0100
> Stefan Krause <st...@minet.uni-jena.de> wrote:
> 
>   | Hi,
>   |
>   | I use torque in the stand-alone version and I try to insert data into a
>   | database table.
>   | I use mysql. The peer classes are created. I compiled my test class
>   | "DBTest" succesfully.
>   | My database table to insert exists and is called "Contributor".
>   | Here is the code:
>   |
>   | package org.openscience.nmrshiftdb;
>   |
>   | public class DBTest
>   | {
>   |     public static void main(String args[])
>   |     {
>   |             Contributor con = new Contributor();
>   |             con.setFirstName("name");
>   |             con.setLastName("name");
>   |             con.setZipCode(1234);
>   |             try
>   |             {
>   |                     ContributorPeer.doInsert(con);
>   |                     con.save();
>   |             }
>   |             catch (Exception exc)
>   |             {
>   |             }
>   |     }
>   | }
>   |
>   | When I do run I get the following exception:
>   |
>   | run:
>   |      [java] Exception in thread "main"
>   | java.lang.ExceptionInInitializerError: java.lang.NullPointerException
>   |      [java] at
>   | org.apache.torque.util.BasePeer.getMapBuilder(BasePeer.java:1922)
>   |      [java] at
>   | org.opensience.nmrshiftdb.BaseContributorPeer.<clinit>(BaseContributorPeer.java:29)
>   |      [java] at org.opensience.nmrshiftdb.DBTest.main(DBTest.java:36)
>   |      [java] Java Result: 1
>   |
>   | Is it because it can't find the BasePeer class?
>   | I would be grateful for an advice.
>   | Thanks in advance.
>   |
>   | Stefan
>   |
>   | --
>   | To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>   | For additional commands, e-mail: <ma...@jakarta.apache.org>
>   |
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: torque: problem inserting data into database table

Posted by Heiko Braun <he...@hlan.org>.
Hi,

i dont have a concrete answer, but i was 
wondering about your code. Isn't it redundent to 
first call doInsert() manually and afterwards call save() 
(which then starts the transaction) ?

Hope that helps,

Heiko
 
On Sat, 19 Jan 2002 19:26:26 +0100
Stefan Krause <st...@minet.uni-jena.de> wrote:

  | Hi,
  | 
  | I use torque in the stand-alone version and I try to insert data into a
  | database table.
  | I use mysql. The peer classes are created. I compiled my test class
  | "DBTest" succesfully.
  | My database table to insert exists and is called "Contributor".
  | Here is the code:
  | 
  | package org.openscience.nmrshiftdb;
  | 
  | public class DBTest
  | {
  | 	public static void main(String args[])
  | 	{
  | 		Contributor con = new Contributor();
  | 		con.setFirstName("name");
  | 		con.setLastName("name");
  | 		con.setZipCode(1234);
  | 		try
  | 		{
  | 			ContributorPeer.doInsert(con);
  | 			con.save();
  | 		}
  | 		catch (Exception exc)
  | 		{
  | 		}
  | 	}
  | }
  | 
  | When I do run I get the following exception:
  | 
  | run:
  |      [java] Exception in thread "main"
  | java.lang.ExceptionInInitializerError: java.lang.NullPointerException
  |      [java]	at
  | org.apache.torque.util.BasePeer.getMapBuilder(BasePeer.java:1922)
  |      [java]	at
  | org.opensience.nmrshiftdb.BaseContributorPeer.<clinit>(BaseContributorPeer.java:29)
  |      [java]	at org.opensience.nmrshiftdb.DBTest.main(DBTest.java:36)
  |      [java] Java Result: 1
  | 
  | Is it because it can't find the BasePeer class?
  | I would be grateful for an advice.
  | Thanks in advance.
  | 
  | Stefan
  | 
  | --
  | To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
  | For additional commands, e-mail: <ma...@jakarta.apache.org>
  | 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>