I hope somebody put this in a faq or the like...

Title: what happens when you implements a MailRepository under OracleDb
Refers to: James 1.2.*, Oracle Server 9i (perhaps 8i and others)

Subtitle: something went wrong, but I can't put my finger on it...

Step to replicate:
- first install james 1.2* and test everything is ok;
- then create the schema (lets say JAMES) and  the table Message in the Db,
  as sketched with mySql example;
- then change the repository def (I forgot the steps at home, but cutting &
pasting
  the mySql defs basically works);
- finally rerun james: even though evrytng is ok, deamon crashed in a weird
way,
  with the weirder exception:
2002.01.24 10:13:34 086 Channel default opened loading broker properties
from file:/var/maildatabase com.workingdogs.town.DataSetException: Error
retrieving primary keys from table
jamesusers: Unable to retrieve primary keys on table jamesusers
        at com.workingdogs.town.ConnDefinition.getSchema

What happend?:
James uses Town lib to serialize messages from / to db: Town knows there is
a table called
"Messages" to analyze before operating: the analysis looks for:
- the type and name of columns;
- the primary key(s);
Introspection is done via getDatabaseMetaData(), but the Oracle
implementation is faulty:

IF you CREATE TABLE MESSAGE(), then the catalog contains an entry MESSAGE
and getDatabaseMetaData() returns data as expected;

IF you CREATE TABLE Message(), then the catalog contains an entry MESSAGE
and getDatabaseMetaData() doesn't find the table and returns empty data;

IF at this point you're rather confused and thinks there's something rotten,
you should
re-read the above sentences thrice and accept as a fact of life:
according to Oracle Support this is *NOT* a bug, instead that's exactly the
logical behaviour (and I'd known it better and not bugged people that
works...).

Finally the solution (by dany, which is me):
you cannot change James and you cannot touch Town, and you
cannot force Oracle to support logic, but you can:

open sqlplus james/james@sid_your_db:

CREATE TABLE MESSAGES(ETC);

CREATE SYNONYM "Messages" FOR MESSAGES;

SELECT * FROM CAT;
-- you should see 2 entries: the first UPPERCASE, the second MixedCase;

COMMIT; -- it always helps;

exit sqlplus;

rerun all the testbed and james: it should work:

hope it helps,
d.




-----Messaggio originale-----
Da: Raghavender Rao [mailto:[EMAIL PROTECTED]]
Inviato: giovedì 24 gennaio 2002 6.25
A: [EMAIL PROTECTED]
Oggetto: PLease Help Me!!!


hi ther,

     I am trying to install JAMES with users repositories stored in
Oracle.Connection eshtablished successfully.But when i try to adduser or
listusers it gives me following Exception..

--------------------------------------------

2002.01.24 10:13:34 086 Channel default opened
loading broker properties from file:/var/maildatabase
com.workingdogs.town.DataSetException: Error retrieving primary keys from
table
jamesusers: Unable to retrieve primary keys on table jamesusers
        at
com.workingdogs.town.ConnDefinition.getSchema(ConnDefinition.java:227
)
        at com.workingdogs.town.TableDataSet.<init>(TableDataSet.java:299)
        at com.workingdogs.town.TableDataSet.<init>(TableDataSet.java:280)
        at
org.apache.james.userrepository.UsersTownRepository.countUsers(UsersT
ownRepository.java:171)
        at
org.apache.james.remotemanager.RemoteManager.parseCommand(RemoteManag
er.java:195)
        at
org.apache.james.remotemanager.RemoteManager.parseRequest(RemoteManag
er.java:117)
        at
org.apache.avalon.blocks.serversocket.ServerSocketAcceptor.run(Server
SocketAcceptor.java:77)
        at org.apache.avalon.utils.recycle.pool.Worker.run(Worker.java:113)

-----------------------------

table has primary keys but still error.

still to add

 in com.workingdogs.town.ConnDefinition class and method getSchema();

------------------------------------------------------
1.           KeyDef keydef = new KeyDef();
2.            try
3.            {
4.                Connection connection1 = getConnection();
5.                try
6.                {
7.                    DatabaseMetaData databasemetadata =
connection1.getMetaData();
8.                    ResultSet resultset1;
9.                    for(resultset1 =
databasemetadata.getPrimaryKeys(connection1.getCatalog(), null, s);
resultset1.next(); keydef.addAttrib(resultset1.getString("COLUMN_NAME")));
10.                   resultset1.close();
11.                   if(keydef.size() == 0)      // this is the cause of
the error.....
12.                       throw new DataSetException("Unable to retrieve
primary keys on table " + s);
13.                   schema.setDefaultKeyDef(keydef);
14.                   schemas.put(s, schema);
15.               }
16.               catch(Exception exception2)
17.               {
18.                   throw new DataSetException("Error retrieving primary
keys from table " + s + ": " + exception2.getMessage());
19.               }
20.               releaseConnection(connection1);
21.            }
22.           catch(Exception exception1)
23.           {
24.               if(exception1 instanceof DataSetException)
25.                   throw (DataSetException)exception1;
26.               else
27.                   throw new DataSetException("Error retrieving schema
info for table " + s + ": " + exception1.getMessage());
28.           }
29.       }
-----------------------------------------------------

 Line 11 is causing ERROR!!! the size of keydef is 0
 and i wrote a small program to test this....
-----------------------------------------------------
     try {
            java.sql.DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());
            int i=0;
            java.lang.String s = "jamesusers";
            java.sql.Connection connection =
java.sql.DriverManager.getConnection("mydatabaseurl","username","password");
            java.sql.Statement statement = connection.createStatement();
            java.sql.DatabaseMetaData databasemetadata =
connection.getMetaData();
            java.sql.ResultSet resultset;
            resultset =
databasemetadata.getPrimaryKeys(connection.getCatalog(),null,s);
            java.lang.System.out.println("The Value of ResultSet is
"+resultset.next());

            /*while(resultset.next()){

               java.lang.System.out.println("The coloums are
"+resultset.getString("COLUMN_NAME"));

            }*/
        }catch(java.lang.Exception exception){

            exception.printStackTrace();
        }
-----------------------------------------------------

The output of this program is :

 The Value of ResultSet is false

I tried with different tables which has primary keys but the output is
same...

Please help me to solve this problem as soon as possible.

Rao





----------------------------------------------------------------------------
----
MSN Photos is the easiest way to share and print your photos: Click Here

Reply via email to