繁体   English   中英

带有Oracle 10 g数据库的Java 8 Swing应用程序

[英]java 8 Swing application with oracle 10 g database

我用Java 8创建了一个Swing项目,并使用Oracle 10g进行数据库连接。 一切都很好,但是当我运行我的项目时,经过几次操作后,我得到以下错误:

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
The Connection descriptor used by the client was:
localhost:1521:xe

我已经在oracle数据库中使用以下查询:

alter system set processes=300 scope=spfile;

但仍然无法正常工作,进程数为40:-

RESOURCE_NAME                processes
CURRENT_UTILIZATION          39
MAX_UTILIZATION              40
INITIAL_ALLOCATION           40
LIMIT_VALUE                  40

我该怎么办?

您好,我使用以下代码进行连接:-

包装连接;

导入java.sql。*;

公共类conn {

Connection con;
Statement st;
ResultSet rs;



public ResultSet GetData(String s) {

    try{

        Class.forName("oracle.jdbc.OracleDriver");
        con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "123456");
        st=con.createStatement();
        //System.out.println("Connected to DataBase to show the result...");
        rs=st.executeQuery(s);

    }

        catch(Exception e)
        {
        System.out.println(e);
                    }
        return rs;

        }



public void UpdateData(String s) {

    try
    {
    Class.forName("oracle.jdbc.OracleDriver");
    con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "123456");
    st=con.createStatement();
    //System.out.println("Connected to the DataBase for Updating the Record...");
    st.executeUpdate(s);
    System.out.println("Record Updated...");


    }

    catch(Exception e1)
    {
    System.out.println(e1); 
    }


}

}

现在,当我想在项目中使用数据库连接时,这些代码位于单独的类中,我只是在创建此类的对象并使用函数。 在我的项目中,我也使用计时器来刷新JTable的数据。 请提供解决方案?

现在解决了。 非常感谢大家的支持。 发生这种情况是因为我没有在我的问题和代码中提到的数据库连接性类中关闭连接。 每当计时器启动时,它都会创建数据库连接类的新实例,而不会关闭旧实例。 现在,我在连接类中创建了close方法,一切都很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM