I'm not sure why you need to use a DataSource to get the Connection. Here is how you can create a connection manually (SQL Server example): Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://" + server + ":" + port + ";DatabaseName=Master;", username, password);
mr green hold could not understand the , problem, actually DataSource is the, feature for builtin connection booling, so, i am also still , looking that , how to connect throug DataSource to the normal database
Context ctx = new InitialContext();DataSource ds = (DataSource)ctx.lookup("jdbc/dsname"); //give the name of ur db connectionConnectiondbConnection = 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 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.
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop