写个数据库连接怎么会内存越界呢。。
代码 :
——————————————————————————————————————————————————————————————————————————————————————
basedao:
package dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import
java.sql.SQLException;
public class BaseDao {
public final static String driver = "oracle.jdbc.driver.OracleDriver";
public final static String url = "jdbc:oracle:thin:@192.168.1.250:1521:YIDEEORC102010";
public final static String dbName = "estock";
public final static String dbPass = "estock";
public Connection getConn() throws
ClassNotFoundException,
SQLException
{
Class.forName(driver);
Connection conn = DriverManager.getConnection(url,dbName,dbPass);
return conn;
}
public void closeAll(Connection conn,PreparedStatement pstmt,ResultSet rs)
{
if(rs != null)
{
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("3333");
}
}
if(pstmt != null)
{
try {
pstmt.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("222");
}
}
if(conn != null)
{
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("111");
}
}
}
public int executeSQL(String preparedSql,String[] param)
{
Connection conn = null;
PreparedStatement pstmt = null;
int num = 0;
try {
conn = getConn();
} catch (Class
NotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("aa");
}
try {
pstmt = conn.prepareStatement(preparedSql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("ccc");
}
if(param != null)
{
for(int i=0;i<param.length;i++)
{
try {
pstmt.setString(i+1, param[i]);
System.out.println("aa");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("qas");
}
}
}
try {
num = pstmt.executeUpdate();
} catch (SQLException&nbs