How use DataSource to get Connection w/o using web and app server? How to set url, userID, password in the DataSource?
Lilac Ezer
Greenhorn
Joined: Apr 08, 2003
Posts: 8
posted
0
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);
Aijaz Soomro
Greenhorn
Joined: Aug 31, 2002
Posts: 17
posted
0
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
Rajeshwari Natarajan
Ranch Hand
Joined: Mar 05, 2003
Posts: 67
posted
0
this is how u do it...
hope this helps..
regards<br />Rajeshwari. N
Aijaz Soomro
Greenhorn
Joined: Aug 31, 2002
Posts: 17
posted
0
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.