新手求助
请问下面这段代码为什么会报错:
package com.tar;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class ConnectionUtils {
private static String url;
private static String driver;
private static String username;
private static String password;
static {
Properties props = new Properties();
try {
// 从属性文件中读取数据库配置信息
props.load(ConnectionUtils.class.getClassLoader()
.getResourceAsStream(
"db_oracle.properties"));
} catch (IOException e) {
e.printStackTrace();
}
if (props != null) {
url = props.getProperty("url");
driver = props.getProperty("driver");
username = props.getProperty("username");
password = props.getProperty("password");
// 装载并注册数据库驱动
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
}
}
}
public static Connection openConnection() throws SQLException {
return DriverManager.getConnection(url, username, password);
}
public static void closeConnection(Connection con) {
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
}
}
public static void closeStatement(Statement stmt) {
try {
if (stmt != null) {
stmt.close();
}
} catch (SQLException e) {
}
}
public static void closeResultSet(ResultSet rs) {
try {
if (rs != null) {
rs.close();
}
} catch (SQLException e) {
}
}
}
db_oracle.properties文件内容:
driver=oracle.jdbc.driver.OracleDriver
url = jdbc:oracle:thin:@localhost:1521:w
name = scott
Password = tiger
错误代码:
java.sql.SQLException: ORA-06550: 第 1 行, 第 7 列:
PLS-00201: 必须声明标识符 'TOTAL_COUNT'
ORA-06550: 第 1 行, 第 7 列:
PL/SQL: Statement ignored
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:202)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1005)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3550)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4710)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
at com.tar.TestCallableStmt.callSpWithOutParam(TestCallableStmt.java:35)
at com.tar.TestCallableStmt.main(TestCallableStmt.java:23)