Results 1 to 2 of 2
- 04-02-2007, 09:12 AM #1
Member
- Join Date
- Mar 2007
- Posts
- 41
- Rep Power
- 0
Data Source :How to get connection inside java
Hi all
How is the java code different if we use the datasource or simple connections ?
I will make it little more clear , I make an ordinary connection using JDBC and later i thought of configuring it in the datasource.xml .How s the get connection method in the java code different
thanks
peiceonly
- 04-02-2007, 10:40 AM #2
Senior Member
- Join Date
- Mar 2007
- Posts
- 134
- Rep Power
- 0
ferosh please paste code inside '[ code ] [ /code ]' block
Java Code:public Connection getDb() throws ClassNotFoundException, SQLException { Connection con=null; try { Class.forName("com.mysql.jdbc.Driver").newInstance (); con = DriverManager.getConnection("jdbc:mysql://localhost/mytest?user=root&password=lroot"); // System.out.println("Connection is established"); } catch(Exception e) { System.out.println("Exception in Connection "+ e); } return con; }
Similar Threads
-
JVM terminated while creating a new Data-Source
By woeko in forum EclipseReplies: 0Last Post: 01-03-2008, 12:28 PM -
Problem inserting values to MySQL tables from the Data Source Explorer
By tip in forum EclipseReplies: 0Last Post: 12-24-2007, 09:47 AM -
Problem for iReport (Data Source )
By tlgkumar in forum Advanced JavaReplies: 1Last Post: 11-27-2007, 07:39 AM -
2 threads sharing a data base connection
By Ed in forum Advanced JavaReplies: 2Last Post: 07-04-2007, 04:41 AM -
Connection to data base
By Daniel in forum JDBCReplies: 2Last Post: 06-07-2007, 04:55 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks