1 |
torben |
292 |
package dk.thoerup.traininfoservice; |
2 |
|
|
|
3 |
|
|
import java.sql.Connection; |
4 |
|
|
import java.sql.SQLException; |
5 |
|
|
|
6 |
|
|
import javax.naming.Context; |
7 |
|
|
import javax.naming.InitialContext; |
8 |
|
|
import javax.naming.NamingException; |
9 |
|
|
import javax.sql.DataSource; |
10 |
|
|
|
11 |
|
|
public class DBConnection { |
12 |
|
|
public static Connection getConnection() throws SQLException, NamingException{ |
13 |
|
|
Context ctx = new InitialContext(); |
14 |
|
|
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/android"); |
15 |
|
|
return ds.getConnection(); |
16 |
|
|
} |
17 |
|
|
} |