DataSource is InstructionTestDB. Lookup is comp/env/InstructionTestDB.
Therefore connection is getting DefaultDS.
Need to map comp/env/InstructionTestDB to InstructionTestDB using jboss.xml.
resource-manager tag I think.
"Weir, John" wrote:
> All,
>
> I have an entity bean that uses a table in there called test which has
four
> columns - txnRefDate, txnSequence, intentId and accountNo.
> But it looks like as soon as I try access this table it complains because
it
> is trying to access the wrong database. It looks like the result of the
JNDI
> lookup is giving me the wrong DataSource
>
> the MLET extracts of files below:
>
> I have read the FAQ and the manuals and can't get anywhere - Appreaciate
any
> suggestions you may have
>
> BTW: Solaris 6 / Sybase 11.9.2.1
>
> jboss.jcml
> *********************************
> <mbean name="DefaultDomain:service=XADataSource,name=InstructionTestDB">
> <attribute
> name="URL">jdbc:sybase:Tds:lnitdss06.fi.gs.com:2010</attribute>
> <attribute name="JDBCUser">donkey</attribute>
> <attribute name="Password">*****</attribute>
> ......
> </mbean>
> *********************************
>
> jboss.conf
> *********************************
> <MLET CODE="org.jboss.jdbc.XADataSourceLoader" ARCHIVE="jboss.jar"
> CODEBASE="../../lib/ext/">
> <ARG TYPE="java.lang.String" VALUE="InstantDB">
> <ARG TYPE="java.lang.String"
> VALUE="org.jboss.minerva.xa.XADataSourceImpl">
> </MLET>
>
> <MLET CODE="org.jboss.jdbc.XADataSourceLoader" ARCHIVE="jboss.jar"
> CODEBASE="../../lib/ext/">
> <ARG TYPE="java.lang.String" VALUE="DefaultDS">
> <ARG TYPE="java.lang.String"
> VALUE="org.jboss.minerva.xa.XADataSourceImpl">
> </MLET>
>
> <MLET CODE = "org.jboss.jdbc.XADataSourceLoader" ARCHIVE="jboss.jar,
> jconn2.jar" CODEBASE="../../lib/ext">
> <ARG TYPE="java.lang.String" VALUE="InstructionTestDB">
> <ARG TYPE="java.lang.String"
> VALUE="org.jboss.minerva.xa.XADataSourceImpl">
> </MLET>
> *********************************
>
> access code:
>
> getConnection(){
> Context initial = new InitialContext();
> DataSource dataSource = (DataSource)
> initial.lookup("java:comp/env/InstructionTestDB");
> return dataSource.getConnection();
> }
>
> public InstructionPK ejbFindByPrimaryKey(InstructionPK primaryKey) throws
> FinderException{
> Connection con = null;
> try{
> con = getConnection();
> System.out.println("connected as " +
> con.getMetaData().getUserName());
> System.out.println("url = " +
> con.getMetaData().getURL());
> PreparedStatement statement =
> con.prepareStatement("select accountNo from test where txnRefDate = ? " +
> " and txnSequence = ? and intentId
=
> ? ");
> }
>
> and the output is
>
> [Instruction] connected as SA
> [Instruction] url = jdbc:HypersonicSQL:hsql://localhost:1476
> [Instruction] TRANSACTION ROLLBACK EXCEPTION:null; nested exception is:
> javax.ejb.EJBException
> [Instruction] java.sql.SQLException: Table not found: TEST in statement
> [select accountNo from test where txnRefDate = 1 and txnSequence = 1 and
> intentId = 1 ]
> [Instruction] at org.hsql.Trace.getError(Trace.java:124)
> .
> .
>
> which is obviously not what I wanted.
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
This message (including any attachments) contains confidential, proprietary
or privileged information intended for a specific purpose and individual(s),
and is protected by law. If you receive this message in error, please
immediately delete it and all copies of it from your system, destroy any
hard copies of it and notify the sender. Any unauthorized disclosure,
copying or distribution of any part of this message, or the taking of any
unauthorized action based on it, is strictly prohibited.
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]