Any body can tell me that how to connect to the database without ejb datbase , i mean there is example, like String dbString = "java:comp/env/jdbc/ZacDB"; InitialContext ic = new InitialContext(); DataSource ds = (DataSource) ic.lookup(dbString); connection = ds.getConnection();
so, i want to connect my database , simple any.mdb, so how should be connected, and what would be the dbString instead, of that above string
Hi, In the example jdbc/ZacDB is the name of the jdbc resource. You have to specify a connection pool for the jdbc resource. The connection pool will contain database parmaeters like user name ,password, and the databse(any.mdb in your case) you want to connect. Hope this helps. Which web/Application server are you using...may be then I can tell you how to create these resources on the server. Get back if you have any issues
Joined: Aug 31, 2002
Context ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup("jdbc/dsname"); //give the name of ur db connectionConnection dbConnection = ds.getConnection(); according to above example i have used the test , which is the name of my microsoft access connection ,build be odbc, there is the exception (no initial context exception )that jdbc/test is not bound in the context, so, any body can tell me that how to bind it in the context. while that connection name is working fine in simple connectivity.