java中手动创建DataSource。

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;

public class Hdf extends BasicDataSource {

public DataSource getDataSource() {
DataSource ds = null;

super.setDriverClassName("oracle.jdbc.driver.OracleDriver");
super.setUrl("jdbc:oracle:thin:@192.168.0.2:1521:xmsm");
super.setUsername("risenetsm");
super.setPassword("qazwsxedc");
try {
ds = super.createDataSource();
} catch (SQLException e) {
e.printStackTrace();
}

return ds;
}

}

你可能感兴趣的:(JAVA)