Hi,
Is there a way to use a JBoss DataSource from a standalone application ?
If I try that, I get a javax.naming.NamingException: java:comp/env namespace
is only available from within a J2EE component
at
com.sun.enterprise.naming.java.javaURLContext.getComponentContext(javaURLCon
text.java:392)
at
com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:51)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at DBconnect.main(DBconnect.java:23)
Thanks for any suggestion,
pascal
This is my simple code sample : (execution stops at the ctx.lookup part...)
public static void main(String[] args)
{
System.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingC
ontextFactory");
System.setProperty("java.naming.provider.url","localhost:1099");
System.setProperty("java.naming.factory.url.pkgs","org.jboss.naming");
Connection conn = null;
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/SkelleDS");
conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM adressen");
while(rs.next()){
System.out.println(rs.getString(1));
}
} catch(NamingException ne) {
ne.printStackTrace(System.out);
} catch(SQLException se) {
se.printStackTrace(System.out);
} finally {
if(conn != null)
try {conn.close();} catch(SQLException e) {}
}
}
}
I tried all combination for the lookup of my named datasource
(java:/SkelleDS etc.), but that does not seem to work...
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]