I am having troubles trying to get a connection to MySQL working. I have
set up the entries in the relevant configuration files, it seems to connect
successfully but I keep getting SQLExceptions like the following:
[UserSession] SQLException
[UserSession] java.sql.SQLException: Table not found: AREA in statement
[select * from area]
[UserSession] at org.hsql.Trace.getError(Trace.java:124)
[UserSession] at org.hsql.Result.<init>(Result.java:70)
[UserSession] at
org.hsql.jdbcConnection.executeHSQL(jdbcConnection.java:644)
[UserSession] at org.hsql.jdbcConnection.execute(jdbcConnection.java:540)
[UserSession] at
org.hsql.jdbcStatement.fetchResult(jdbcStatement.java:499)
[UserSession] at
org.hsql.jdbcStatement.executeQuery(jdbcStatement.java:37)
[UserSession] at
org.jboss.minerva.jdbc.StatementInPool.executeQuery(StatementInPool.java:144
)
[UserSession] at
au.com.constructnet.ejb.UserSessionEJB.getUserDetails(UserSessionEJB.java:66
)
[UserSession] at
au.com.constructnet.ejb.UserSessionEJB.loginUser(UserSessionEJB.java:46)
[UserSession] at java.lang.reflect.Method.invoke(Native Method)
[UserSession] at
org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Stateles
sSessionContainer.java:472)
[UserSession] at
org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:254)
[UserSession] at
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSe
ssionInstanceInterceptor.java:87)
[UserSession] at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:14
4)
[UserSession] at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
[UserSession] at
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.jav
a:271)
[UserSession] at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerI
nvoker.java:163)
[UserSession] at java.lang.reflect.Method.invoke(Native Method)
[UserSession] at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
[UserSession] at sun.rmi.transport.Transport$1.run(Unknown Source)
[UserSession] at java.security.AccessController.doPrivileged(Native
Method)
[UserSession] at sun.rmi.transport.Transport.serviceCall(Unknown Source)
[UserSession] at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown
Source)
[UserSession] at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
[UserSession] at java.lang.Thread.run(Unknown Source)
JBoss is JBoss-2.0_FINAL. MySQL is 3.23.28-gamma. JDBC Driver is MM.MySQL
2.0.3.
Here is the entry from jboss.properties:
jdbc.drivers=org.gjt.mm.mysql.Driver,org.hsql.jdbcDriver,org.enhydra.instant
db.jdbc.idbDriver
Here is the entry from jboss.conf:
<MLET CODE="org.jboss.jdbc.XADataSourceLoader" ARCHIVE="jboss.jar"
CODEBASE="../../lib/ext/">
<ARG TYPE="java.lang.String" VALUE="constructnetdb">
<ARG TYPE="java.lang.String"
VALUE="org.jboss.minerva.xa.XADataSourceImpl">
</MLET>
Here is the entry from jboss.jcml:
<mbean name="DefaultDomain:service=XADataSource,name=constructnetdb">
<attribute name="Properties"></attribute>
<attribute name="URL">jdbc:mysql://localhost/constructnet</attribute>
<attribute name="GCMinIdleTime">1200000</attribute>
<attribute name="JDBCUser">clintonh</attribute>
<attribute name="MaxSize">10</attribute>
<attribute name="Password">PASSWORD</attribute>
<attribute name="GCEnabled">false</attribute>
<attribute name="InvalidateOnError">false</attribute>
<attribute name="TimestampUsed">false</attribute>
<attribute name="Blocking">true</attribute>
<attribute name="GCInterval">120000</attribute>
<attribute name="IdleTimeout">1800000</attribute>
<attribute name="IdleTimeoutEnabled">false</attribute>
<attribute name="LoggingEnabled">true</attribute>
<attribute name="MaxIdleTimeoutPercent">1.0</attribute>
<attribute name="MinSize">0</attribute>
</mbean>
Here is my code:
String dbName = "java:/comp/env/jdbc/ConstructNET";
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);
Connection conn = ds.getConnection;
Statement s = conn.createStatement();
ResultSet resxx = s.executeQuery("select * from area");
while (resxx.next()) {
System.out.println(resxx.getString(2));
}
Here is my ejb-jar.xml:
<resource-ref>
<description>ConstructNET database (mysql)</description>
<res-ref-name>jdbc/ConstructNET</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
And finally, the jboss.xml:
<resource-managers>
<resource-manager res-class="org.jboss.ejb.deployment.JDBCResource">
<res-name>jdbc/ConstructNET</res-name>
<res-jndi-name>constructnetdb</res-jndi-name>
</resource-manager>
</resource-managers>
When JBoss starts, it gives the proper messages:
[JDBC] Loaded JDBC-driver:org.gjt.mm.mysql.Driver
...
[constructnetdb] Initializing
[constructnetdb] Initialized
...
[constructnetdb] Starting
[constructnetdb] XA Connection pool constructnetdb bound to
java:/constructnetdb
The mysql admin utility shows a connection by user clintonh to database
constructnet, which is correct. I can use the mysql client program to
connect to the same database using the same username and password and run
the same query and it works. I have also used another Java client program
to do the same. For example, the following code works:
import java.sql.*;
public class testjdbc {
public static void main(String[] Args) {
try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection Conn = DriverManager.getConnection(
"jdbc:mysql://localhost/constructnet","clintonh","PASSWORD");
Statement Stmt = Conn.createStatement();
ResultSet RS = Stmt.executeQuery("SELECT * from area");
while (RS.next()) {
System.out.println(RS.getString(2));
}
RS.close();
Stmt.close();
Conn.close();
}
catch (Exception E) {
E.printStackTrace();
}
}
}
Can anyone shed any light on this?
Regards,
Clinton Hastings
***************************************************************************
Privileged or confidential information may be contained in this electronic
mail message. If this message is received in error, please immediately
delete it and all copies of it from your system, and notify the sender.
Under no circumstances are the contents of this email to be used, directly
or indirectly, if you are not the intended recipient.
Any views expressed within this electronic mail message are those of the
sender, unless expressed otherwise within the electronic mail message,
and the sender is authorised to state such views on the company's behalf.
Golden Circle Limited will not accept any liability for loss or damage,
via direct or indirect means, that may be as a result of the contents of
this electronic mail message or the attachments it contains.
***************************************************************************
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]