OracleÖдò¿ªÓα곬³ö×î´óÖµ
ÏòOracleÊý¾Ý¿â±íÖвåÈëÊ®¼¸ÍòÌõÊý¾Ý£¬¿ÉÊǵ±²åÈë3Íò¶àÌõºó£¬³ÌÐò¾ÍÅ×
Java´úÂë
ORA-01000 maximum open cursors exceeded
ORA-01000 maximum open cursors exceeded
Òì³£ÐÅÏ¢¡£GoogleÁËÒì³£ÐÅÏ¢£¬µÃÖªÕâÑùµÄ´íÎóºÜÈÝÒ׳öÏÖÔÚJava´úÂëÖеÄÖ÷ÒªÔÒòÊÇ£ºJava´úÂëÔÚÖ´ÐÐconn.createStatement()ºÍconn.prepareStatement()µÄʱºò£¬Êµ¼ÊÉ϶¼ÊÇÏ൱ÓÚÔÚÊý¾Ý¿âÖдò¿ªÁËÒ»¸öcursor¡£ÓÈÆäÊÇ£¬Èç¹ûÄãµÄcreateStatementºÍprepareStatementÊÇÔÚÒ»¸öÑ»·ÀïÃæµÄ»°£¬¾Í»á·Ç³£ÈÝÒ׳öÏÖÕâ¸öÎÊÌâ¡£ÒòΪÓαêÒ»Ö±ÔÚ²»Í£µÄ´ò¿ª£¬¶øÇÒûÓйرա£
Ò»°ãÀ´Ëµ£¬ÎÒÃÇÔÚдJava´úÂëµÄʱºò£¬createStatementºÍprepareStatement¶¼Ó¦¸ÃÒª·ÅÔÚÑ»·ÍâÃæ£¬¶øÇÒʹÓÃÁËÕâЩStatmentºó£¬¼°Ê±¹Ø±Õ¡£×îºÃÊÇÔÚÖ´ÐÐÁËÒ»´ÎexecuteQuery¡¢executeUpdateµÈÖ®ºó£¬Èç¹û²»ÐèҪʹÓýá¹û¼¯£¨ResultSet£©µÄÊý¾Ý£¬¾ÍÂíÉϽ«Statment¹Ø±Õ£¨statementName.close()£©¡£
ÏÂÃæ½«´úÂ븽ÉÏ
Å×Òì³£´úÂ룺
Java´úÂë
Connection conn = DBUtils.getConnection();//»ñÈ¡Êý¾Ý¿âÁ¬½Ó
PreparedStatement pstmt = conn.prepareStatement("select statement...");
ResultSet rset = pstmt.executeQuery();
while (rset.next()) {
PreparedStatement pst=conn.prepareStatement("insert statement...");//¿ªÆôÒ»¸öÓαê
//pst.setXXX()...;
pst.executeUpdate();
pst=conn.prepareStatement("another insert statement");//ÔÙ¿ªÆôÒ»¸öÓαê
//pst.setXXX()...;
pst.executeUpdate();
pst=conn.prepareStatement("third insert statement");//¿ªÆôÒ»¸öÓαê
//pst.setXXX()...;
&
Ïà¹ØÎĵµ£º
±¾ÎĽéÉÜÁËÈçºÎÀûÓÃsqlplus copy ÃüÁîÔÚÁ½¸öÊý¾Ý¿â¼ä×ªÒÆÊý¾Ý
ÎÞÐèÓõ½dblink, Á½¸öÊý¾Ý¿â¼ä²»ÐèÖ±½ÓͨѶ£¬µ±È»£¬ÐèÒªÓÐÒ»¸öclient¶ÎÄÜͬʱÒÔsqlplusÁ¬½Óµ½Á½¸öÊý¾Ý¿â
ÎÊÌâµÄÌá³ö
ÂÛ̳ÉÏÓÐÈËÌá³öÕâÑùµÄÎÊÌ⣺
¼ÙÉèÓÐÁ½¸öÊý¾Ý¿â,·Ö±ð´¦ÓÚÁ½¸ö²»Í¬µÄÍøµ«ÓÐÒ»¸ö¿Í»§»ú°²ÁËÁ½¿éÍø¿¨¿ÉÒÔͬʱÁ¬µ½Á½¸öÊý¾Ý¿âÇëÎÊÈç¹û²»Í¨¹ýÔÚ¿ ......
ºÜ¾ÃûÓиüÐÂOracleÊý¾Ý¿âµÄÎÄÕÂÁË£¬½ñÌìС±àÕûÀíÁËÒ»ÏÂ×ÊÁÏ£¬ºÍ´ó¼Ò·ÖÏíOracleµÄÌåϵ¡£oracleµÄÌåϵºÜÅÓ´ó£¬ÒªÑ§Ï°Ëü£¬Ê×ÏÈÒªÁ˽âoracleµÄ¿ò¼Ü¡£ÔÚÕâÀ¼òÒªµÄ½²Ò»ÏÂoracleµÄ¼Ü¹¹£¬ÈóõѧÕß¶ÔoracleÓÐÒ»¸öÕûÌåµÄÈÏʶ¡£
1¡¢ÎïÀí½á¹¹£¨ÓÉ¿ØÖÆÎļþ¡¢Êý¾ÝÎļþ¡¢ÖØ×öÈÕÖ¾Îļþ¡¢²ÎÊýÎļþ¡¢¹éµµÎļþ¡¢ÃÜÂëÎļþ×é³É£© ¿Ø ......
×¢£ºÏÂÃæÖ»ÊÇÎÒ´ÖÁӵļǼһÏ£¬×Ô¼ºÔÚ¿ª·¢ÖÐËùѧµÄÒ»²¿·Ö×ÊÁÏ£¡
1£® µÚÒ»¡¢ÊÇÏÂÔØÒ»¸ö“Oracle9i¿Í»§¶Ë¾«¼ò°æ.exe”¿Í»§¶Ë£¬È»ºó°ÑËü°²×°µ½CÅÌÏÂÃæ¡£
È»ºó°ÑÎÒÃÇ×Ô¼ºÅäÖúõĔ tnsnames.ora”Îļþ£¬¸´¸ÇC:\oracle\ora90\network\adminÏÂÃæµÄtnsnames.oraÎļþ¡£
2£® ÔÚVS2005¿ª·¢¹¤¾ßÖ ......
¶ÔÓÚx$µÄÇé¿ö
SQL> grant select on sys.x$bh to t1;
grant select on sys.x$bh to t1
ERROR at line 1:
ORA-02030: can only select from fixed tables/views
¶ÔÓÚfixed tables/viewsÖ»ÄÜselect
Èç¹ûÏë°Ñx$bhµÄselectȨÏÞgrant¸øÆäËûÓû§Ôõô°ìÄØ,¿ÉÒÔ±äͨһÏÂ
SQL> create view xbh as select * from sys.x$ ......