Connecting to SQLAnywhere8
nrichards Apr 11, 2002 3:41 PMHi,
I've been trying to connect to SQLAnywhere from JBoss for what seems a very long time now, but with no success. I am currently getting the following exception on start-up:
java.lang.NullPointerException
at org.jboss.pool.jdbc.xa.XAPoolDataSource.getConnection(Unknown Source)
at org.jboss.jdbc.XADataSourceLoader.startService(XADataSourceLoader.java:412)
at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103)
at java.lang.reflect.Method.invoke(Native Method)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(ConfigurationService.java:967)
at $Proxy0.start(Unknown Source)
at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
at java.lang.reflect.Method.invoke(Native Method)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at org.jboss.Main.(Main.java:208)
at org.jboss.Main$1.run(Main.java:110)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.Main.main(Main.java:106)
[18:00:19,000,ConfigurationService] Unexpected error
I'm not too sure that having overcome this everything will be ok. Am I along the right lines with the following ?
-------------------
jboss.jcml
com.sybase.jdbc2.jdbc.SybDriver
org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
stb
jdbc:sybase:Tds:host.domain.com:40000/database
dba
sql
(I'm starting the database like this ....
dbeng8 -c 2m -x tcpip(serverport=40000) C:\stb\databases\stb.db -n stb )
------------------
jboss.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">
<enterprise-beans>
<ejb-name>TestEJB</ejb-name>
<resource-ref>
<res-ref-name>jdbc/stb</res-ref-name>
<jndi-name>java:/stb</jndi-name>
</resource-ref>
</enterprise-beans>
-------------------
ejb-jar-xml
<ejb-jar>
<enterprise-beans>
<ejb-name>TestEJB</ejb-name>
...
<resource-ref>
Data source for STB database
<res-ref-name>jdbc/stb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</enterprise-beans>
</ejb-jar>
-------------------
TestBean
Connection con = null;
PreparedStatement ps = null;
ResultSet result = null;
ArrayList list = new ArrayList();
try {
DataSource ds = (DataSource) iContext.lookup("java:comp/env/jdbc/stb");
con = ds.getConnection();
ps = con.prepareStatement("SELECT COUNTRY_NAME FROM "+
"ISO_COUNTRY ORDER BY COUNTRY_NAME");
result = ps.executeQuery();
while (result.next()) {
list.add(result.getString(1));
}
}
catch (Exception e) {
Debug.out(e.getMessage());
}
finally {
try {
if (result != null) result.close();
if (ps != null) ps.close();
if (con != null) con.close();
}
catch (SQLException se) {se.printStackTrace();}
}
I'd really appreciate some help if someone's got the time.
tia,