You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by kidong <Ki...@public.uni-hamburg.de> on 2001/04/19 20:01:43 UTC

how to connect to database

hello,

sorry, even if i have tried connecting to database to get all criteria
functions, but
it failed. thus i'm asking the question again.

it is my fundamental problem with connecting to mysql database.
my test application is built with the below steps:

1. build default layout
2. with torque, peers to two databases are automatically generated as
following:

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

<!--
==================================================================== -->
<!--                                                                      --
>
<!-- T U R B I N E  P R O J E C T  S C H E M
  -->
<!--                                                                      --
>
<!--
==================================================================== -->
<!-- This is an bugtracker Turbine project
        -->
<!--
==================================================================== -->

<app-data>

<database name="BUGTRACKER">

  <table name="ISSUE">
    <column name="ISSUE_ID" required="true" autoIncrement="true"
            primaryKey="true" type="INTEGER"/>
    <column name="TITLE" size="255" type="VARCHAR"/>
    <column name="DESCRIPTION" size="255" type="VARCHAR"/>
    <column name="STEPSTOREPRODUCE" size="255" type="VARCHAR"/>
    <column name="PRODUCT" size="64" type="VARCHAR"/>
    <column name="STATUS" size="64" type="VARCHAR"/>
    <column name="PRIORITY" size="64" type="VARCHAR"/>
    <column name="SEVERITY" size="64" type="VARCHAR"/>
    <column name="VERSION" size="64" type="VARCHAR"/>
    <column name="FREQUENCY" size="64" type="VARCHAR"/>
    <column name="ASSIGNEDTO" size="64" type="VARCHAR"/>
    <column name="REPORTEDBY" size="64" type="VARCHAR"/>
    <column name="FIXEDBY" size="64" type="VARCHAR"/>
    <column name="FIXEDINVERSION" size="64" type="VARCHAR"/>
    <column name="REMARKS" size="255" type="VARCHAR"/>
    <column name="REPORTINGDATE" type="DATE"/>
    <column name="BELONGTO" size="32" type="VARCHAR"/>
    <column name="URL" size="255" type="VARCHAR"/>
    <column name="KS" type="INTEGER"/>
    <column name="KD_NR" type="INTEGER"/>
  </table>

</database>

<database name="ZEF">

  <table name="MITARBEITER">
    <column name="KUERZEL" required="true" autoIncrement="true"
            primaryKey="true" size="5" type="VARCHAR"/>
    <column name="VORNAME" size="20" type="VARCHAR"/>
    <column name="NAME" size="30" type="VARCHAR"/>
    <column name="FON" size="30" type="VARCHAR"/>
    <column name="HANDY" size="20" type="VARCHAR"/>
    <column name="EMAIL" size="50" type="VARCHAR"/>
    <column name="PASSWORT" size="10" type="VARCHAR"/>
  </table>

  <table name="STATUS">
    <column name="ID" required="true" autoIncrement="true"
            primaryKey="true" type="INTEGER"/>
    <column name="KUERZEL" size="5" type="VARCHAR"/>
    <column name="GRP_ID" type="INTEGER"/>
  </table>

  <table name="KUNDEN">
    <column name="KD_NR" required="true" autoIncrement="true"
            primaryKey="true" type="INTEGER"/>
    <column name="NAME" size="50" type="VARCHAR"/>
  </table>

  <table name="PROJEKTE">
    <column name="KS" required="true" autoIncrement="true"
            primaryKey="true" type="INTEGER"/>
    <column name="KUERZEL" size="5" type="VARCHAR"/>
    <column name="KD_NR" type="INTEGER"/>
    <column name="NAME" size="50" type="VARCHAR"/>
    <column name="BESCHREIBUNG" size="2550" type="VARCHAR"/>
    <column name="STATUS" size="5" type="VARCHAR"/>
  </table>

</database>

</app-data>

and in torque.prop, it is set as following:

databaseUrl = jdbc:mysql://127.0.0.1/bugtracker
databaseDriver = org.gjt.mm.mysql.Driver
databaseUser = root
databasePassword =
databaseHost = 127.0.0.1

3. two database sql  is result of it.
4. in TR.properties, database setting is like:

database.default.driver=org.gjt.mm.mysql.Driver
database.default.url=jdbc:mysql://127.0.0.1/bugtracker?user=root
database.default.username=root
database.default.password=

5.and in my code to retrieve all the table rows:

public void doPerformThis (RunData data, Context context) throws Exception
{
       Criteria crit = new Criteria();
       Vector v = org.apache.turbine.MitarbeiterPeer.doSelect( crit );
       context.put("co_worker", v);
}

6. and now exception is thrown like this:

[Thu Apr 19 19:39:29 GMT+02:00 2001] -- INFO -- Initializing service (late):
MapBrokerService
[Thu Apr 19 19:39:29 GMT+02:00 2001] -- INFO -- Initializing service (late):
PoolBrokerService
[Thu Apr 19 19:39:29 GMT+02:00 2001] -- INFO -- IDBroker thread was started.
[Thu Apr 19 19:39:29 GMT+02:00 2001] -- WARN -- IDBroker is being used with
db: ZEF
 which does not support transactions.  It is possible to
 generate duplicate keys, if multiple JVM's are used or other
 means are used to write to the database.
[Thu Apr 19 19:39:29 GMT+02:00 2001] -- ERROR -- Turbine.handleException:
Connection object is null!
[Thu Apr 19 19:39:29 GMT+02:00 2001] -- ERROR --
 Exception:  java.sql.SQLException: Connection object is null!
 Stack Trace follows:
 java.sql.SQLException: Connection object is null!
 at
org.apache.turbine.util.db.pool.DBConnection.getConnection(DBConnection.java
:356)
 at org.apache.turbine.om.peer.BasePeer.executeQuery(BasePeer.java:1245)
 at org.apache.turbine.om.peer.BasePeer.executeQuery(BasePeer.java:1215)
 at org.apache.turbine.om.peer.BasePeer.executeQuery(BasePeer.java:1166)
 at org.apache.turbine.om.peer.BasePeer.doSelect(BasePeer.java:1095)
 at
org.apache.turbine.BaseMitarbeiterPeer.doSelectVillageRecords(BaseMitarbeite
rPeer.java:174)

7. well, connection object is null!

i don't understand how to connect db, even though with a small connection my
old turbine application worked fine
with this code:

Criteria crit = new Criteria();
Vector v = org.apache.turbine.BaseMitarbeiterPeer.doSelect( crit,
GetDBConnection.getAnotherDBConnection() );

any help would be very appreciated.

thanks,

kidong




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