ora-12519,找不到合适的服务处理程序

时间:2015-04-07 15:48:10

标签: java oracle jdbc

每当我在代码中使用无限循环时,我得到ORA-12519 没有合适的服务处理程序 -exception。但是,此代码在其他系统中运行良好。

这是我的代码

public static void main(String args[]) {
    try {
        Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
        String dbHost = "localhost";
        String database = "scott";
        String dbUsername = "scott";
        String dbPassword = "scott";
        String smsReceiver = "";

        String dbUrl = "jdbc:oracle:thin:@localhost:1521:xe";

        while (true) {
            ResultSet rs = null;
            conn = DriverManager.getConnection(dbUrl, dbUsername, dbPassword);

            try {
                Statement smnt = null;
                smnt = conn.createStatement();
                String sql = "select count(*) from ozekismsin";
                rs = smnt.executeQuery(sql);
                rs.next();

                int count = rs.getInt(1);
                if (count != 0) {
                    System.out.println("success");
                    sql = "select * from ozekismsin";
                    rs = smnt.executeQuery(sql);
                    rs.next();
                    String msg = rs.getString("msg");
                    // smsReceiver=rs.getString("sender");
                    System.out.println(msg);
                    StringTokenizer st = new StringTokenizer(msg, " ");
                    st.nextToken();
                    String source = st.nextToken();
                    st.nextToken();
                    String dest = st.nextToken();
                    System.out.println(source + " " + dest);
                    PreparedStatement preparedStatement = null;
                    sql = "select id from new1 where name=?";
                    preparedStatement = conn.prepareStatement(sql);
                    preparedStatement.setString(1, source);

                    rs = preparedStatement.executeQuery();

                    rs.next();

                    int s = rs.getInt("id");
                    System.out.println(source + " " + dest);
                    sql = "select id from new1 where name=?";
                    preparedStatement = conn.prepareStatement(sql);
                    preparedStatement.setString(1, dest);
                    System.out.println(s);
                    rs = preparedStatement.executeQuery();
                    rs.next();
                    int d = rs.getInt(1);
                    a = s;

                    test1 ob = new test1();
                    ob.dijkstra(s, d);

                    String sqlInsert = "INSERT INTO "
                            + "ozekismsout (receiver,msg,status) "
                            + "VALUES " + "('" + smsReceiver + "','"
                            + message + "','send')";

                    if (smnt.executeUpdate(sqlInsert) != 0) {
                        System.out.println("OK");
                        System.out.println(message);
                    } else {
                        System.out.println("ERROR");
                    }
                    sql = "delete from ozekismsin";
                    smnt.executeQuery(sql);
                    sql = "commit";
                    smnt.executeQuery(sql);
                } // end of if

                smnt.close();
                conn.close();
            } // end of try in while
            finally {
                try {
                    rs.close();
                } catch (Exception e) {
                    System.out.println("exception caught");
                }
            } // end of finally
        } // end of while
    } // end of outer try
    catch (Exception ex) {
        System.out.println("Exception: " + ex.getMessage());
        ex.printStackTrace();
    }
} // end of main

此代码在其他系统中完美运行。但是这里只有在我删除无限循环时才有效。

请任何人帮助我。

1 个答案:

答案 0 :(得分:0)

错误ORA-12519可能是由当前连接使用(例如,concurrernt会话)引起的,超出了Oracle实例允许的最大数量。

请求您的DBA告诉您实施了哪些连接限制 - 这些设置是特定于数据库的,某些值具有默认值。问。

正如你的代码循环@AlexPoole指出你正在耗尽资源 - 例如,你可能正在创建一系列连接而不是释放它们。我无法确定。 12519错误是连接资源问题。期。你怎么做的,我不知道。