[英]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.