3dfb15ad3458b058d269abf21d29bda24c91a409.svn-base 608 B

123456789101112131415161718192021
  1. package test.main.DB;
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. import java.sql.SQLException;
  5. public class TestBatchDbConnection{
  6. private static final String DRIVERNAME = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
  7. public Connection getConnection() throws SQLException, ClassNotFoundException {
  8. Class.forName(DRIVERNAME);
  9. Connection connection = DriverManager
  10. .getConnection("jdbc:sqlserver://192.168.100.183;databaseName=HND110109_0625;user=sa;password=sa");
  11. return connection;
  12. }
  13. public void freeConnection(Connection conn) throws SQLException {
  14. conn.close();
  15. }
  16. }