I am not even sure if I am referring to the correct terms, but having managed to 
successfully connect to data by passing the id and password for the database via code, 
I am now trying to set up this information in the JBoss environment so that I can use 
connection pooling, and not have the password for the database in my code?

I have some sample code below, my question is what do I have to do to be able to use 
the 'MyDS' datasource??

// Step 1. Look up the DataSource
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("jdbc/MyDS");

// Step 2. Get a connection from the pool
Connection conn = ds.getConnection();

// Step 3. Execute query
Statement stmt = conn.createStatement();
stmt.execute("SELECT * FROM USERID.EMPLOYEE");

// Step 4. Get the results
ResultSet rs = stmt.getResultSet();
while (rs.next()) {
   String firstCol = rs.getString(1);
   int secondCol   = rs.getInt(2);
   ...
}

// Step 5. Return connection to the pool
conn.close();

I think this means adding something to the 'standardjbosscmp-jdbc.xml' file? I cannot 
find a _simple_ example I can look at to get me started, any pointers would be greatly 
appreciated!

Thanks

Chris Parsons


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3834599#3834599

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3834599


-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to 
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to