Unclear about closing ResultSets
Please provide clarification: The JavaDoc for ResultSets says that you don't have to explicitly close ResultSet objects since the RS will be closed when its defining Statement is closed or when the RS is garbage collected.
The Oracle JDBC Developer's Guide and Reference states (in the section titled "Closing the Result Set and Statement Objects"):
"You must explicitly close the ResultSet and Statement objects after you finish using them. This applies to all
ResultSet and Statement objects you create when using the Oracle JDBC drivers. The drivers do not have
finalizer methods; cleanup routines are performed by the close() method of the ResultSet and Statement
classes. If you do not explicitly close your ResultSet and Statement objects, serious memory leaks could
occur. You could also run out of cursors in the database."
So, does the Oracle driver operate differently than the JDBC standard in this regard?
The JavaDoc for ResultSets says that you don't have to explicitly close ResultSet objects since the RS will be closed when its defining Statement is closed or when the RS is garbage collected.In Oracle JDBC, if you close the statement, then the result set is also closed, unless you obtained the result set as an OUT parameter from a stored procedure or function that returns a REF CURSOR.
However, it is definitely not prudent to wait until the result set is garbage collected, since you have no explicit control over that! Depending on your database setup, you'll typically be able to open a couple dozen statements before you start running out of database cursors.
This is even more important if you are using SQLJ: there statements are automatically managed for you, so you'll never have to worry about closing them. However, if you do not close result sets (called iterators in SQLJ), the associated statement will be kept around and stays open (again, it might be garbage collected or it might not - no guarantees).
Similar Messages
-
Please Help ! Exception in closing resultset,statement.
In an application developed on , i am closing the resultsets and statements in finally block as
finally {
if (resultset != null) resultset .close();
if (statement != null) statement.close();
the above block does not take care of exceptions that might arise while closing resultset/statement. Please help with this:
what the conditions exceptions may arise in closing resultset/statements.
when does the garbage collector free such resources and what are the implications of not catching exception while closing - can this cause database handle leaks.
Please help!I don't know what exceptions might occur, but since the close() method can throw SQLException, your program has to catch it. Maybe if you close twice, the second time will throw an exception? Anyway, it doesn't really matter, you still have to write a try-catch around it. What you do there is up to you -- you could ignore it (which is what I do) or you could end the program with a message.
When does the garbage collector free those resources? The garbage collector only frees memory. Nothing else. And the garbage collector will free a ResultSet object only when there are no references to it anywhere in your program. That doesn't mean just in code that you wrote, but anywhere in code that's running in your program. For example, the Statement object that produced the ResultSet might hold a reference to it. However, the API documentation for ResultSet does say that when the garbage collector does free a ResultSet object, it will automatically close it.
However, the best practice is to close ResultSet and Statement objects when you are finished with them, and not rely on garbage collection to clean up after you. -
At work I set my PC to not remember history for privacy reasons.
I always have many tabs open, and the warning about closing multiple tabs was a good thing - but now it only works if it remembers history!
I have the "Warn me when closing...." box checked AND all of the lines in about:config regarding these warnings are set to true. I have tried turning it off and back on, restarted the PC.
I discovered this yesterday with FF 3.something, tried updating to FF4.The "Use custom settings for history" selection allows to see the current history and cookie settings, but selecting this doesn't make any changes to history and cookie settings.
Firefox shows "Use custom settings for history" as an indication that at least one of the history and cookie settings is not the default to make you aware that changes were made.
If all History settings are default then the custom settings are hidden and you see "Firefox will: (Never) Remember History".
"Never Remember History" means that Private Browsing is active and "Always use private browsing mode" gets a checkmark.
You need to remove the checkmark on "Always use private browsing mode" to leave Private Browsing mode or chose the "Remember History" setting.
*https://support.mozilla.org/kb/Private+Browsing -
Supplier is getting emails about closed notifications
Hi,
Supplier is getting emails about closed notifications while earlier he used to not receive such notifications. The message name is EMAIL_PO_PDF.
The Autoclose_FYI parameter is set to Y already in our case.
Which parameter decides the end date for this type of notifications ? As we see end date is sometimes only 1 min and for others it is 20-30 days.
Earlier the supplier was receiving only FYI notification emails like " +_KPN - Standard Purchase Order 3039086, 0_+ ". Now, he is receiving Closed notification emails like " _+*Closed*: KPN - Standard Purchase Order 3039086, 0+_ ". How come the supplier is suddenly receiving FYI notification emails with prefix CLOSED ?
Please suggest why they are generated and how to stop these CLOSED FYI email notifications as supplier does not want to receive them.
Below is an example email:
========================================================================
From: Production Workflow Mailer (D1556P) [mailto:[email protected]]
Sent: Thursday, July 12, 2012 3:45 PM
To: [email protected]
Subject: Closed: KPN - Standard Purchase Order 3039086, 0
You earlier received the notification shown below. That notification is now closed, and no longer requires your response. You may simply delete it along with this message.
From ROOS, C
To [email protected]
Sent 18-JUN-12 22:10:57
ID 865518
Please review the purchase order and any other document attached to this message.
============================================================================
Regards,
Natasha
Edited by: 947278 on Jul 19, 2012 7:05 AMPl do not post duplicates - Supplier is getting Closed notifications for message name EMAIL_PO_PDF - continue the discussion in your previous thread - if the Docs do not help, pl log an SR with Support
-
Question about closed captioning
Hello all,
I have a quick question about closed captioning. I've output broadcast shows to Mini-DV which has been transferred to BETA SP with no problems. Another station requires the BETA tapes with closed captioning on them. The company doing the captioning has requested that the tapes be originals that have never been dubbed to BETA. Does it make a difference? Or can the same DV tapes I supplied the first station still be used?
Thanks in advance...Thrillcat's got it.
You might want to ask for a captioned DV (more likely DVCam) dub as well, so you can have the CC on any dubs you do. DV and variants store CC in a mysterious place called "VAUX data", and as long as the deck respects it (many mini-DV decks don't) the CC will be passed through FireWire. You can FireWire it back into FCP and it will stay with the program.
If you're doing the above ask if the video itself is a digital DV clone. That may not be the normal case, as standard old-fashioned Line 21 is normally inserted in an analogish way.
Oliver, your posts still don't make it clear if DV is the best format you can output. That should be the major factor in what you give them. If you are equipped to output to BetaSP, DVCPro50, etc. while avoiding a DV compression, your program will thank you. -
Want to know about the resultset closed exception
hi,
in my java programming, i have used two resultset objects.also two statement object have used.
but the first resultset object is closed immediately after the second resultset object was created.
then i have to use two resultset objects for my coding.
what can i do?
plzsnd me reply.You cannot have two result set simultaneously because you have only one cursor.
To resolve this, you could store the data into a collection (a list form example) from the first result set that you close it. Then you open the second one and do your tasks using the collection.
I think your problem could be resolved using PLSQL,
hth -
I'm getting desperate for a solution to this problem (as is the rest of the development team!).
Basically we've been trying to create a system that automatically assigns values (frequencies) to objects (nodes) based on a rule set. Each node contains a varying number of sub-objects (radios) and each radio needs one frequency. The database has been set up and has test data for our Solution class to go through. However, we've run into an odd problem where our ResultSets are suddenly closing.
The classes work like this:
Database Broker (handles connection to DB, as well as executeQuery and executeUpdate statements.)
Entry Broker (Holds all SQL statements for data retrieval in various methods. Each method contains an SQL statement to access data, and code to format that data into something useable by the main class.
Solution/Main class (Contains methods to use the data from the Entry Broker to test valid solutions. Certain rules apply to assigning frequencies to radios and this class ensures that the data applies to these rules before it writes the data back to the DB (via the EntryBroker).
The problem we continually run into is that whilst the ResultSets work fine in the Entry Broker, they are closed when they return to the Main class.
Here's the catch: It seems in most cases that only the FIRST ResultSet returned in each method is closed, the remaining ResultSets work fine. We worked around this problem by creating a 'dummy' ResultSet, which obtained data from the database which was never used (the project name). We put this in its own try catch bracket so it would not interrupt the project.
It worked fine for a few classes, but for others (notably the following one) it was ineffective. We've searched and searched but we cannot find anyone with a similar complaint (except a few people who have commented about ODBC version problems). Our ODBC version is 3.520.7713.0
Here's an example method from the Solution class (The entire class is over 1000 lines):
// Method to test Harmonic resonance for nodes within 10m
private boolean resonanceGlobal (boolean tstResonanceG, double txFreq, double rxFreq, int distance) {
System.out.println("Beginning global harmonic resonance check");
try {
// Getting Nodes
rsNode2 = eBroker.getNodes(projectNo);
// node loop
while (rsNode2.next()) {
System.out.println("602 Test Marker GHarm 1");
// get next node, store in nodeTemp
nodeTemp = rsNode2.getInt(1);
// System out to show which nodes will pass if statement
System.out.println(node + " compare to " + nodeTemp);
// avoid testing the same node against itself
if (nodeTemp != node) {
// distance check (only neccesary within 10m)
System.out.println("Test Marker Before Distance check");
distance = getDistance(node, nodeTemp, distance);
System.out.println("Test Marker After Distance check");
// distance check if statement
if (distance <= 10) {
System.out.println("618 Test Marker GHarm 2");
// get the radios of the node, foreign node
rsRadiosTemp = eBroker.getRadios(node);
rsDummy = eBroker.getDummy(projectNo);
rsRadios2 = eBroker.getRadios(nodeTemp);
// This dummy ResultSet normally fails so that
// the other ResultSets perform normally
try {
rsDummy.next();
} // end try
catch (java.sql.SQLException dummyException) {
System.out.println("dummyException " + dummyException);
} // end catch
// radio loop
while (rsRadiosTemp.next()) { // error occurs here
System.out.println("627 Test Marker GHarm 3");
// loop for foreign node radios
while (rsRadios2.next()) {
System.out.println("631 Test Marker GHarm 4");
// get next radio
radioTemp = rsRadios2.getInt(1);
// get the TX and RX of the radio
genericTX = getTX(radioTemp);
radioTempCon = getConnection(radioTemp);
genericRX = getTX(radioTempCon);
// calculate bounds for harmonics test
txLo = ((txFreq * 2) - genericTX) - 4; // 4Mhz below TX harmonics check
txHi = ((txFreq * 2) - genericTX) + 4; // 4Mhz above TX harmonics check
rxHi = ((rxFreq * 2) - genericRX) + 4; // 4Mhz above RX harmonics check
rxLo = ((rxFreq * 2) - genericRX) - 4; // 4Mhz below RX harmonics check
// checks TX and RX of foreign radio against TX, RX of current radio for separation
if ((txLo > genericTX && txHi < genericTX) || (rxLo > genericRX && rxHi < genericRX)) {
tstResonanceG = false;
break;
} //end if
else {
tstResonanceG = true;
} // end else
} //end foreign radio loop
// breaking out of loops for return
if (tstResonanceG == false)
break;
} // end radio loop
rsRadios2.close();
rsRadiosTemp.close();
} // end sameradio check
} // end distance check
}// end node loop
rsNode2.close();
} // end try
// Catch statement to stop from crashing in the
// event of an error during SQL statements.
catch (java.sql.SQLException resonanceGlobalException) {
// Prints out the error message produced
System.out.println(resonanceGlobalException);
} // end catch
// returns result
return tstResonanceG;
} //end checkHarmonicResonanceGlobal()
My apologies if it is a little hard to read, but the indenting is accurate. The Entry Broker methods which this method uses are here:
public ResultSet getNodes (int projectNo) {
// creating SQL statement
sqlStatement = "SELECT nodeNo from tblNode WHERE projectNo = " + projectNo;
System.out.println(sqlStatement);
// executing SQL statement
rsNodes = db.runQuery(sqlStatement);
// returns ResultSet
return rsNodes;
} // end getNodes
// Method to get the distance between any two nodes
public int getDistance (int projectNo, int node, int tempNode) {
ResultSet rsX1; // Used for obtaining the X-coord of node 1
ResultSet rsX2; // Used for obtaining the X-coord of node 2
ResultSet rsY1; // Used for obtaining the Y-coord of node 1
ResultSet rsY2; // Used for obtaining the Y-coord of node 2
double distance = 0; // Used in Global checks
int dist = 0; // Used in Global checks
int x1 = 0; // Used in calculating distance
int x2 = 0; // Used in calculating distance
int y1 = 0; // Used in calculating distance
int y2 = 0; // Used in calculating distance
int xDist = 0; // Used in calculating distance
int yDist = 0; // Used in calculating distance
int distint = 0; // Used to store converted values
try {
// get the X and Y co-ordinates of both nodes
sqlStatement = "SELECT xCoord FROM tblNode WHERE nodeNo = " + node + " AND projectNo = " + projectNo;
rsX1 = db.runQuery(sqlStatement);
rsX1.next();
x1 = rsX1.getInt(1);
sqlStatement = "SELECT yCoord FROM tblNode WHERE nodeNo = " + node + " AND projectNo = " + projectNo;
rsY1 = db.runQuery(sqlStatement);
rsY1.next();
y1 = rsY1.getInt(1);
sqlStatement = "SELECT xCoord FROM tblNode WHERE nodeNo = " + tempNode + " AND projectNo = " + projectNo;
rsX2 = db.runQuery(sqlStatement);
rsX2.next();
x2 = rsX2.getInt(1);
sqlStatement = "SELECT yCoord FROM tblNode WHERE nodeNo = " + tempNode + " AND projectNo = " + projectNo;
rsY2 = db.runQuery(sqlStatement);
rsY2.next();
y2 = rsY2.getInt(1);
} // end try
catch (java.sql.SQLException getDistanceException) {
System.out.println(getDistanceException);
// calculating distance
yDist = y2 - y1;
xDist = x2 - x1;
// perform pythagoras theorem for distance
dist = (xDist * xDist) + (yDist * yDist);
distance = java.lang.Math.sqrt(dist);
Double roundFreqTemp = new Double(freqTemp);
distint = roundFreqTemp.intValue() ;
return distint;
} // end get distance method
// Method to get all the radios in a node
public ResultSet getRadios(int node) {
ResultSet rsRadios; // Used for obtaining radios in a node
// creating sql Statement
sqlStatement = "SELECT * FROM tblRadio WHERE nodeNo =" + node;
System.out.println(sqlStatement);
// executing sql Statement
rsRadios = db.runQuery(sqlStatement);
System.out.println("EB Test Marker 1: Line 261");
// returning radio no
return rsRadios;
}//end getRadio
public double getTX(int radioTemp){
double txTemp = 0; // Used for storing TX of a radio
int freqNoTemp = 0; // Used for storing the frequency ID
rsDummy = getDummy(projectNo);
// creating SQL statement
sqlStatement ="Select frequencyNo from tblRadio where radioNo = " + radioTemp;
System.out.println(sqlStatement);
// executing SQL statement
rsTX = db.runQuery(sqlStatement);
try {
System.out.println("Test Marker EB1: 317");
try {
rsDummy.next();
} // end try
catch (java.sql.SQLException dummyException) {
System.out.println("dummyException" + dummyException);
} // end catch
System.out.println("Test MarkerEB2: 330");
// moving to first position in rs
rsTX.next();
System.out.println("Test MarkerEB3: 334");
// obtaining data from rs
freqNoTemp = rsTX.getInt(1);
System.out.println("Test MarkerEB4: 337");
rsTX.close();
} // end try
catch (java.sql.SQLException rsTXException) {
System.out.println("rsTXExeption: " + rsTXException);
} // emd catch
System.out.println("Frequency No is: " + freqNoTemp);
rsDummy = getDummy(projectNo);
sqlStatement = "Select frequency from tblFreq where frequencyNo = " + freqNoTemp;
System.out.println(sqlStatement);
rsRX = db.runQuery(sqlStatement);
try {
try {
System.out.println("Test MarkerEB6: 361");
rsDummy.next();
} // end try
catch (java.sql.SQLException dummyException) {
System.out.println("dummyException" + dummyException);
} // end catch
System.out.println("Test MarkerEB5: 373");
rsRX.next();
System.out.println("Test MarkerEB7: 376");
txTemp = rsRX.getDouble(1);
System.out.println("Test MarkerEB8: 379");
rsRX.close();
} // end try
catch (java.sql.SQLException rxException) {
System.out.println("rxException " + rxException);
} // end catch
System.out.println("393 Before return");
return txTemp;
} //end getTX
public int getConnection(int radio) {
int nodeCon = 0; // Used to return the connected node no
ResultSet rsConnection; // Used for obtaining the foreign radio
// creating SQL statement
sqlStatement = "SELECT radioNo FROM tblRadio where recRadio = " + radio;
System.out.println(sqlStatement);
// executing SQL statement
rsConnection = db.runQuery(sqlStatement);
try {
// moving to first position in rs
rsConnection.next();
// obtaining data from rs
nodeCon = rsConnection.getInt(1);
} // end try
catch (java.sql.SQLException getConnectionException) {
System.out.println("getConnectionException : " + getConnectionException);
} // end catch
// returns node no.
return nodeCon;
And finally, the dummy rs:
// Dummy method to fix resultSet closed error
public ResultSet getDummy (int projectNo) {
sqlStatement = "Select projectName from tblProject where projectNo = " + projectNo;
System.out.println(sqlStatement);
rsDummy = db.runQuery(sqlStatement);
return rsDummy;
Here is some sample output that we have:
----jGRASP exec: java MainGui
slider value constructor: 50
116: if(singleton==null) {
120: singleton=new Resolvotron
Connection to D/Base establised
Select projectName from tblProject where projectNo = 3
Init OK. Beginning solve process
main OK: beginning frequency assign process
SELECT nodeNo from tblNode WHERE projectNo = 3
267: Node number = 2
SELECT * FROM tblRadio WHERE nodeNo =2
EB Test Marker 1: Line 261
Test Marker 1: Line 289
298: Radio number = 4
Test Marker 5: Line 308
Test Marker 3: Line 313
SELECT frequency from tblFreq WHERE projectNo = 3
125.5
Beginning test process
Test Marker 4: Line 386
Beginning check 257072
Test Marker 6: Line 774
70 Mhz Margin = false
Beginning local 10Mhz separation check
SELECT * FROM tblRadio WHERE nodeNo =2
EB Test Marker 1: Line 261
Getting TX of radio: 4
Select projectName from tblProject where projectNo = 3
Select frequencyNo from tblRadio where radioNo = 4
Test Marker EB1: 317
dummyExceptionjava.sql.SQLException: ResultSet is closed
Test MarkerEB2: 330
Test MarkerEB3: 334
Test MarkerEB4: 337
Frequency No is: 2
Select projectName from tblProject where projectNo = 3
Select frequency from tblFreq where frequencyNo = 2
Test MarkerEB6: 361
dummyExceptionjava.sql.SQLException: ResultSet is closed
Test MarkerEB5: 373
Test MarkerEB7: 376
Test MarkerEB8: 379
393 Before return
432: getting connection
SELECT radioNo FROM tblRadio where recRadio = 4
438: getting TX of radio: 6
Select projectName from tblProject where projectNo = 3
Select frequencyNo from tblRadio where radioNo = 6
Test Marker EB1: 317
dummyExceptionjava.sql.SQLException: ResultSet is closed
Test MarkerEB2: 330
Test MarkerEB3: 334
Test MarkerEB4: 337
Frequency No is: 2
Select projectName from tblProject where projectNo = 3
Select frequency from tblFreq where frequencyNo = 2
Test MarkerEB6: 361
dummyExceptionjava.sql.SQLException: ResultSet is closed
Test MarkerEB5: 373
Test MarkerEB7: 376
Test MarkerEB8: 379
393 Before return
java.sql.SQLException: ResultSet is closed
10 Mhz Local = true
Beginning 10 Mhz separation check
SELECT nodeNo from tblNode WHERE projectNo = 3
Node number is 2
10 Mhz Global = false
Beginning local harmonic resonance check
SELECT * FROM tblRadio WHERE nodeNo =2
EB Test Marker 1: Line 261
Select projectName from tblProject where projectNo = 3
Select frequencyNo from tblRadio where radioNo = 4
Test Marker EB1: 317
dummyExceptionjava.sql.SQLException: ResultSet is closed
Test MarkerEB2: 330
Test MarkerEB3: 334
Test MarkerEB4: 337
Frequency No is: 2
Select projectName from tblProject where projectNo = 3
Select frequency from tblFreq where frequencyNo = 2
Test MarkerEB6: 361
dummyExceptionjava.sql.SQLException: ResultSet is closed
Test MarkerEB5: 373
Test MarkerEB7: 376
Test MarkerEB8: 379
393 Before return
SELECT radioNo FROM tblRadio where recRadio = 4
Select projectName from tblProject where projectNo = 3
Select frequencyNo from tblRadio where radioNo = 6
Test Marker EB1: 317
dummyExceptionjava.sql.SQLException: ResultSet is closed
Test MarkerEB2: 330
Test MarkerEB3: 334
Test MarkerEB4: 337
Frequency No is: 2
Select projectName from tblProject where projectNo = 3
Select frequency from tblFreq where frequencyNo = 2
Test MarkerEB6: 361
I'll leave it at that, since the program goes into an endless loop. The dummy Exceptions are our dummy resultsets crashing so the rest can survive. The other stuff is from different methods. You should be able to locate the logic of the program by following the System.outs
Test Markers with EB refer to the Entry Broker.
Any help would be appreciated since we cannot find any other way of running this class successfully.
SteveOk problem solved...
Basically I was calling one ResultSet after another. Thanks to the Database Broker's structure, this was killing the first ResultSet. I fixed up the loops so that ResultSets were only ever called just before they were needed, and it fixed the problem. The only other errors were simple logic faults which I drummed out in short order. Thanks for the help everyone! -
Not closing ResultSet, but not getting ORA-01000
I have an application that is generating the familiar ORA-01000 error.
Whilst investigating the problem, I wrote a small test program. In the test program I tried to get the ORA-01000, but I don't get it (has anyone ever complained about not getting ORA-01000 before?!)
connection = DriverManager.getConnection("<connection string>");
String sql = "SELECT c1 FROM pdtab2 WHERE Id>=? AND Id<=?";
PreparedStatement ps = connection.prepareStatement(sql);
for (int i = 1; i <= 30000; ++i)
ps.setInt(1, i-1);
ps.setInt(2, i+1);
if (i % 100 == 0)
System.out.println("i=" +i);
System.out.println("getCurrentOpenCursors(connection)="
+getCurrentOpenCursors(connection));
try
rs = ps.executeQuery();
while (rs.next())
result = rs.getInt(1);
catch (SQLException e2)
e2.printStackTrace();
finally
// Do nothing! Do not close the result set
}getCurrentOpenCursors does:
select count(*) AS COUNT from v$open_cursor where user_name like 'me'
I have reduced OPEN_CURSORS down from 300 to 100, but getCurrentOpenCursors always returns less that what it is set to. Suggesting that OPEN_CUSRORS is not a limit, but rather a pool size?
The result set returns more than one record, I never close the result set, yet I do not get an ORA-01000 error. I have tried auto-commit true and false on the connection. Is the prepared statement closing its previous result set on each new iteration of the loop, hence stopping me getting a problem?
I am using Oracle version 10.2.0.1, the corresponding ojdbc14.jar, and Java 1.4.
Thanks,
PaulHere is a program that does that for you.
To fix the program, un-comment the line 24 of the code and run again.
C:\> type TestCursors.java
import java.lang.* ;
import java.util.* ;
import java.sql.* ;
import oracle.jdbc.* ;
public class TestCursors
public static void main(String[] args) throws SQLException, ClassNotFoundException
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection("jdbc:oracle:oci:@localhost:1521:ORCL");
ResultSet rs ;
PreparedStatement ps ;
for (int i = 1; i <= 30000; ++i)
String sql = "SELECT 20 FROM scott.emp WHERE deptno = ?";
ps = connection.prepareStatement(sql);
ps.setInt(1, 10);
try
rs = ps.executeQuery();
rs.close() ;
//ps.close() ;
catch (SQLException e2)
System.out.println("The value if i is " + i) ;
throw e2 ;
C:\> javac TestCursors.java
C:\> java TestCursors
The value if i is 301
Exception in thread "main" java.sql.SQLException: ORA-01000: maximum open cursors exceeded
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:671)
at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:597)
at oracle.jdbc.driver.T2CPreparedStatement.executeForDescribe(T2CPreparedStatement.java:570)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1030)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1123)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3284)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3328)
at TestCursors.main(TestCursors.java:22)
C:\> -
Too many connections - even after closing ResultSets and PreparedStatements
I'm getting a "Too many connections" error with MySQL when I run my Java program.
2007-08-06 15:07:26,650 main/CLIRuntime [FATAL]: Too many connections
com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Too many connections
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:921)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:812)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3269)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1182)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2670)I researched on this and found out that I wasn't closing the ResultSet and the PreparedStatement.
The JDBC connection is closed by a central program that handles connections (custom connection pooling).
I added the code to close all ResultSets and PreparedStatements, and re-started MySQL as per the instructions here
but still get "Too many connections" error.
A few other things come to mind, as to what I may be doing wrong, so I have a few questions:
1) A few PreparedStatements are created in one method, and they are used in a 2nd method and closed in the 2nd method
does this cause "Too many connections" error?
2) I have 2 different ResultSets, in nested while loops where the outer loop iterates over the first ResultSet and
the inner loop iterates over the second ResultSet.
I have a try-finally block that wraps the inner while loop, and I'm closing the second ResultSet and PreparedStement
in the inner while loop.
I also have a try-finally block that wraps the outer while loop, and I'm closing the first ResulSet and PreparedStatement
in the outer while loop as soon as the inner while loop completes.
So, in the above case the outer while loop's ResultSet and PreparedStatements remain open until the inner while loop completes.
Does the above cause "Too many connections" error?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following is relevant sections of my code ( it is partially pseudo-code ) that shows the above 2 cases:
init( Connection jdbcConnection ){
String firstSQLStatement = "....";
PreparedStatement ps1 = jdbcConnection.prepareStatement( firstSQLStatement );
String secondSQLStatement = "....";
PreparedStatement ps2 = jdbcConnection.prepareStatement( secondSQLStatement );
String thirdSQLStatement = "....";
PreparedStatement ps3 = null;
ResultSet rsA = null;
try{
ps3 = jdbcConnection.prepareStatement( thirdSQLStatement );
rsA = ps3.executeQuery();
if( rsA.next() ){
rsA.getString( 1 );
}finally{
if( rsA != null )
rsA.close();
if( ps3 != null )
ps3.close();
//Notice, how ps1 and ps2 are created here but not used immediately, but only ps3 is
//used immediately.
//ps1 and ps2 are used in another method.
run( Connection jdbcConnection ){
ResultSet rs1 = ps1.executeQuery();
try{
while(rs1.next()){
String s = rs1.getString();
ps2.setString(1, s);
ResultSet rs2 = ps2.executeQuery();
try{
while(rs2.next()){
String s2 = rs2.getString();
}finally{
if( rs2 != null )
rs2.close();
if( ps2 != null )
ps2.close();
}catch( Exception e ){
e.printStackTrace();
}finally{
if( rs1 != null )
rs1.close();
if( ps1 != null )
ps1.close();
//Notice in the above case rs1 and ps1 are closed only after the inner
//while loop completes.
}I appreciate any help.Thanks for your reply.
I will look at the central connection pooling mechanism ( which was written by someone else) , but that is being used by many other Java programs others have written.
They are not getting this error.
An addendum to my previous note, I followed the instructions here.
http://dev.mysql.com/doc/refman/5.0/en/too-many-connections.html
There's probably something else in my code that is not closing the connection.
But I just wanted to rule out the fact that opening a PreparedStatement in one method and closing it in another is not a problem.
Or, if nested ResultSet loops don't cause the problem.
I've read in a few threads taht "Too many connections" can occur for unclosed RS and PS , and not just JDBC connections. -
I have code that creates dynamic SQL statements in a loop to search for a value in a table. The Where clause is changed in each iteration of the loop until the value is found or the loop finishes. The code looks something like this:
(Sorry for the crappy formatting of the code. I tried indenting lines, but when I previewed it, it aligned everything. Damn )
/* NOTE: variables were changed to fit in this page better */
for( int i = 9; i >=0;i--) {
SelectSQL = new StringBuffer("SELECT col FROM tab WHERE ");
for( int j = 0; j <= i;j++) {
SelectSQL.append( "col" + j + "ID = " + Val[j]);
if( j != i ) { SelectSQL.append(","); }
stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY );
rs = stmt.executeQuery(SelectSQL.toString());
if( rs.next() ) {
ValID = rs.getLong(1);
/* TODO: Should I be closing these in loops? */
rs.close();
stmt.close();
if( ValID > 0 ) { break; }
My question is: Do I need to close the resultset(rs) and statement(stmt) at the bottom of the loop? That does not seem very efficient to me, but I am not sure. Any advice would be greatly appriciated. Thanks for your time.declare the statement out of the loop and close it on the
end (also out of the loop) so you reuse the statement each time,
if the ResultSet is empty it closes, also if you loop through it it closes itself, when it is empty, but i recommend to close it each time you use it anyway (in the loop)
don't forget, only select statements return a resultset .. others (delete, update) don't -
Getting java.lang.NullpointerException while closing resultset aft using it
Hi,
I kindly request to share your ideas reg. my problem.
I am opening a database connection using connection pool and i am using two or more resultsets and statement objects.I am closing these objects at the end of their usage.But i am getting java.lang.NullpointerException when i close them(if i don't close them it works fine). what might be the reason. Had i did any thing wrong in the code.
please view the code
public String storeNewConnection(String CIRCLE,String DIVISION,String SUB_DIVISION,String SECTION,String CONSUMER_NAME,String FATHER_NAME,String STREET_NAME,String DOOR_NO,String TOWN_CITY,String LAND_MARK,String PINCODE,String STDCODE,String PHONE_NO,String EMAIL,String NEIGHBOUR_SCNO,String DOCUMENT_CODE,String LT_APR_NO,String year1,String month1,String day1,String PCBNO,String CONSUMER_STATUS,String SOCIAL_GROUP,String CATEGORY_SUPPLY,String LOCATION_PREMISES,String PURPOSE_OF_SUPPLY,String DURATION,String LOAD_TYPE,String CONNECTED_LOAD,String CONTRACTED_LOAD,String APPLICATION_FEE,String DEVELOPMENT_CHARGES,String SECURITY_DEPOSIT,String ADDL_SECURITY_DESPOSIT,String DEPOSITED_THRU,String DD_CHEQUE_DETAILS,String year2,String month2,String day2,String REMARKS,String POLE_NO)
int count=0;
Statement st=null;
ResultSet rs=null,rs1=null,rs2=null,rs3=null;
PreparedStatement pst=null;
String result="",query="",sysDate="",sysDate2="";
String reg_no = "";
try
st=con.createStatement();
//Check dates with sys date
String date1 =null;
String date2 =null;
if(! (year1.equals("") || month1.equals("") || day1.equals("")) )
date1=day1+"-"+month1+"-"+year1;
rs2=st.executeQuery("select round(to_date('"+date1+"','dd-Mon-yyyy')-to_date(sysdate,'dd-Mon-yy')) from dual");
rs2.next();
if(rs2.getInt(1) != 0)
return "false";
if(! (year2.equals("") || month2.equals("") || day2.equals("")) )
date2=day2+"-"+month2+"-"+year2;
rs3=st.executeQuery("select round(to_date('"+date2+"','dd-Mon-yyyy')-to_date(sysdate,'dd-Mon-yy')) from dual");
rs3.next();
if(rs3.getInt(1) != 0)
return "false";
rs1=st.executeQuery("select to_char(sysdate,'yyyyMONdd'),to_char(sysdate,'dd-Mon-yyyy') from dual");
rs1.next();
sysDate=rs1.getString(1);
sysDate2=rs1.getString(2);
rs=st.executeQuery("select max(SERIAL_NO) from NEW_CONNECTIONS where to_char(sysdate,'yyyy') = to_char(REG_DATE,'yyyy') and to_char(sysdate,'mm') = to_char(REG_DATE,'mm') and SUB_DIVISION_CODE = "+SUB_DIVISION+" and DIVISION_CODE = "+DIVISION+" and CIRCLE_CODE = "+CIRCLE+" ");
if(rs.next())
count = rs.getInt(1);
count++;
else
count=1;
query="insert into NEW_CONNECTIONS ( "+
" REG_NO,SERIAL_NO,REG_DATE,CIRCLE_CODE,DIVISION_CODE,SUB_DIVISION_CODE,SECTION_CODE, "+
" CONSUMER_NAME,FATHER_NAME,STREET_NAME,DOOR_NO,TOWN_CITY,LAND_MARK,PINCODE, "+
" STDCODE,PHONE_NO,EMAIL,NEIGHBOUR_SCNO,DOCUMENT_CODE,LT_APR_NO,LT_APR_DATE, "+
" PCBNO,CONSUMER_STATUS,SOCIAL_GROUP,CATEGORY_SUPPLY,LOCATION_PREMISES,PURPOSE_OF_SUPPLY,"+
" DURATION,LOAD_TYPE,CONNECTED_LOAD,CONTRACTED_LOAD,APPLICATION_FEE,DEVELOPMENT_CHARGES, "+
" SECURITY_DEPOSIT,ADDL_SECURITY_DEPOSIT,DEPOSITED_THRU,DD_CHEQUE_DETAILS,DD_CHEQUE_DATE,REMARKS,APPLICATION_STATUS,POLE_NO) "+
" values(?,?,'"+sysDate2+"',?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pst = con.prepareStatement(query);
String cnt ="";
if(count <= 9)
cnt="0000";
else if(count <= 99)
cnt="000";
else if(count <= 999)
cnt="00";
else if(count <= 9999)
cnt="0";
cnt+=Integer.toString(count);
reg_no = CIRCLE+DIVISION+SUB_DIVISION+SECTION+"N"+cnt+sysDate;
int serial_no =count;
int pin = 0;
if(!PINCODE.equals(""))
pin =Integer.parseInt(PINCODE);
int std = 0;
if(!STDCODE.equals(""))
std = Integer.parseInt(STDCODE);
int status = Integer.parseInt(CONSUMER_STATUS);
int social_group = Integer.parseInt(SOCIAL_GROUP);
int supply = Integer.parseInt(CATEGORY_SUPPLY);
int location = Integer.parseInt(LOCATION_PREMISES);
int purpose = Integer.parseInt(PURPOSE_OF_SUPPLY);
int duration = Integer.parseInt(DURATION);
int laod_type = Integer.parseInt(LOAD_TYPE);
float conn_load = Float.parseFloat(CONNECTED_LOAD);
int cont_load = 0;
if(!CONTRACTED_LOAD.equals(""))
cont_load =Integer.parseInt(CONTRACTED_LOAD);
int app_fee = Integer.parseInt(APPLICATION_FEE);
int dev_chg = Integer.parseInt(DEVELOPMENT_CHARGES);
int sec_dep = Integer.parseInt(SECURITY_DEPOSIT);
int addl_sec_dep = 0;
if(!ADDL_SECURITY_DESPOSIT.equals(""))
addl_sec_dep =Integer.parseInt(ADDL_SECURITY_DESPOSIT);
int dep_thru = Integer.parseInt(DEPOSITED_THRU);
pst.setString(1,reg_no);
pst.setInt(2,serial_no);
pst.setString(3,CIRCLE);
pst.setString(4,DIVISION);
pst.setString(5,SUB_DIVISION);
pst.setString(6,SECTION);
pst.setString(7,CONSUMER_NAME);
pst.setString(8,FATHER_NAME);
pst.setString(9,STREET_NAME);
pst.setString(10,DOOR_NO);
pst.setString(11,TOWN_CITY);
pst.setString(12,LAND_MARK);
pst.setInt(13,pin);
pst.setInt(14,std);
pst.setString(15,PHONE_NO);
pst.setString(16,EMAIL);
pst.setString(17,NEIGHBOUR_SCNO);
pst.setString(18,DOCUMENT_CODE);
pst.setString(19,LT_APR_NO);
pst.setString(20,date1);
pst.setString(21,PCBNO);
pst.setInt(22,status);
pst.setInt(23,social_group);
pst.setInt(24,supply );
pst.setInt(25,location);
pst.setInt(26,purpose);
pst.setInt(27,duration);
pst.setInt(28,laod_type);
pst.setFloat(29,conn_load );
pst.setInt(30,cont_load);
pst.setInt(31,app_fee);
pst.setInt(32,dev_chg);
pst.setInt(33,sec_dep);
pst.setInt(34,addl_sec_dep);
pst.setInt(35,dep_thru );
pst.setString(36,DD_CHEQUE_DETAILS);
pst.setString(37,date2);
pst.setString(38,REMARKS);
pst.setInt(39,1);
pst.setString(40,POLE_NO);
pst.executeUpdate();
result=reg_no;
rs.close();
rs=null;
rs1.close();
rs1=null;
rs2.close();
rs2=null;
rs3.close();
rs3=null;
st.close();
st=null;
pst.close();
pst=null;
catch(Exception e)
e.printStackTrace();
result="false";
return result;
finally
if (rs != null)
try
rs.close();
catch (SQLException e)
rs = null;
if (rs1 != null)
try
rs1.close();
catch (SQLException e)
rs1 = null;
if (rs2 != null)
try
rs2.close();
catch (SQLException e)
rs2 = null;
if (rs3 != null)
try
rs3.close();
catch (SQLException e)
rs3 = null;
if (st != null)
try
st.close();
catch (SQLException e)
st = null;
if (pst != null)
try
pst.close();
catch (SQLException e)
pst = null;
return result;
Also plz help me to improve the code if necessary so that it will work fine for multiple users
thaks & regards
Prasanth.CThanks a lot.
i replaced the code below
if (rs != null)
try
rs.close();
catch (SQLException e)
rs = null;
if (rs1 != null)
try
rs1.close();
catch (SQLException e)
rs1 = null;
if (rs2 != null)
try
rs2.close();
catch (SQLException e)
rs2 = null;
if (rs3 != null)
try
rs3.close();
catch (SQLException e)
rs3 = null;
if (st != null)
try
st.close();
catch (SQLException e)
st = null;
if (pst != null)
try
pst.close();
catch (SQLException e)
pst = null;
instead of blindly closing the resultsets and statements
now it works fine.
One more thing, is my code structurally correct, i mean the variables, try...catch blocks,results,statements,database connections and overall coding. whether it looks like professional code.
thaks & regards,
Prasanth.C -
Closing resultset and statements
Hi!
I just got told that I do not need to close my resultsets and statements in the code, it it enough that the connection are closed. Is this correct?
Eg:
public method myMethod() {
ResultSet rs = null;
Statement sqlStmt = null;
try {
query = "SELECT something";
rs = sqlStmt.executeQuery(query);
if (rs.next())
do something...
// close rs
if (rs != null) {
rs.close();
rs = null;
sqlStmt.close();
sqlStmt = null;
} // end try
catch (errors)...
finally {
if (con != null) { <-- Is this line enough to close everything and release connections?
try {
con.close();
catch (exception)...
} // end finallyNo, you have to explicitly close the resultset, statement, and connection in order to release resources allocated to each of them. Closing the connection will only relase the connection, not the resultset, and statement.
you could do all of it in the finally as follows:
finally {
try {
if (rs != null) {
rs.close();
if (stmt != null) {
stmt.close();
if (conn != null) {
conn.close();
} catch (Exception e) {}
also there is no need to set rs = null, stmt = null after the close() -
I updated to Firefox 4 yesterday. I updated my preferences, including checking the box that commands Firefox to "warn me when closing multiple tabs." Despite this, Firefox does not warn me and closes all tabs at quit. In short, I lose all my tabs whenever I quit Firefox. Please advise.
Firefox 4 saves the previous session automatically, so there is no longer need for the dialog asking if you want to save the current session.<br />
Use "Firefox > Quit Firefox" if you want to restore multiple windows.<br />
You can use "Firefox > History > Restore Previous Session" to get the previous session at any time.<br />
There is also a "Restore Previous Session" button on the default <b>about:home</b> Home page.<br />
Another possibility is to use:
* [http://kb.mozillazine.org/Menu_differences Firefox > Preferences] > General > Startup: "When Firefox Starts": "Show my windows and tabs from last time"
You can set the warn prefs on the <b>about:config</b> page to <b>true</b> via the right-click context menu or toggle the value with a double left-click.
* browser.showQuitWarning, see http://blog.zpao.com/post/3174360617/about-that-quit-dialog
* browser.tabs.warnOnClose, see http://kb.mozillazine.org/About%3Aconfig_entries
* browser.warnOnQuit , see http://kb.mozillazine.org/browser.warnOnQuit
* browser.warnOnRestart , see http://kb.mozillazine.org/browser.warnOnRestart
To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
If you see a warning then you can confirm that you want to access that page.<br />
You can use the Filter bar at to top of the about:config page to locate a pref more easily. -
Unclear about requirements/information for Edge vs Contract plans.
I am currently on a 8GB/70 Shared data plan with a corporate discount. I have 4 smart phones and 2 iPads. My total bill is $241.60 + Taxes. Our contract on all 4 phones is now up as of 2/1/15. I have been asking questions about switching to the edge plan. We plan on keeping the new phones for 2 years so all we care about is total cost.
I have received completely different answers to my questions depending on who I talk to. I think we'll save about $550 over 24 months on Edge if we switch to the 10GB/$80 plan. Here are the questions I asked and the answers I was given. Answer #1 is from a Verizon phone rep. Answer #2 is from a Costco person. We are planning on getting a 6 16GB, 6 64GB, 6+ 16GB, and 6+ 64GB. Can someone help make clear what answer is right to each question even though they seem to always be polar opposites.
Questions:
1. If I switch to edge do I have to trade in my current phones even though they are out of contract? Answer #1: Yes you must turn in all phones to Verizon. Answer #2: No you can keep your phones since you have already met your contract requirements.
2. If I pay off my phone after 24 months do I keep the $25/month discount/line? Answer #1: When your phones are paid off your line charge will have the discount removed. Answer #2: They won't remove the charge unless someone manually removes the discount. They won't pay someone to go remove all those discounts on all those edge plans.
3. Say I only wanted to get 3 phones for now and keep one off contract could I get the edge discount on the 4th phone? Answer #1: Never. Answer #2: Depends. They can't do it at Costco but if I call over and over and be nice someone might add it to the 4th line for me.
4. Once all four edge phones are paid off and it has been 24 months do I have to turn in phones to get new edge phones? Answer #1: You must turn in phones for new phones. Answer #2: Once you have paid off phones they are yours to keep. The only time you have to turn in phones is if you don't pay off entire amount say 75% then you have to turn in phones to get new phones.
5. Are the taxes lower/line on edge because I am assuming they don't tax the payment for the phone and some of the taxes/fee are based on percentage? I didn't get an answer on this.
In addition to the questions above can someone make sure my math is correct?
Contract 8GB/$70/month: $70 - 8.4 discount + $40x4 + $20(ipads) = $241.60/month. Up front costs $1028 + $140 (activation fees) from costco = $1168 total up front.
Edge 10GB/$80/month: $80 - 9.6 discount + $15x4 + $20(ipads) = $150.40/month + $124.97/month (phone payoff for 24months) = $275.37/month and no activation fees or phone upfront cost (costco pays sales tax and gives fifty per line back on first bill for each phone).
That means we are paying 34.37 extra a month for 24 months = 824.88 instead of the 1168 upfront fees which is about 300 cheaper. That is if we don't have any tax savings and doesn't include the 200 credit for edge with Costco.
Anything I am missing I am just trying to understand what the gotchas are and if there are any downsides to Edge that I don't know about since I am not getting straight answers.thank you Snn5 and ummgood I am sorry.. the only question I failed to answer was .. at the end of the 2 yrs with a EDGE device ,, if you chose NOT to EDGE UP ..meaning turn in the device your purchased and upgrade to continue on the plan.. If you don't wish to Edge Up you must pay off the remaining balance of your Verizon Edge device, either in full or according to the scheduled monthly installments. After your Edge device is paid off, you can purchase a new device under a 2-year service agreement. this is listed in the link I attached for you... and was the reason I stated above the review the link.
the EDGE is just a feature that helps customers upgrade their device by allowing them to make installment payments ,,, giving them a slight discount on the access line to help ease the normal cost...they are given 2 yrs to satisfy their agreement,,, at the end of the period or anytime during they have the option to EDGE UP ,, which allows them to change out the device by trading in the original EDGE device for a new one and starting the cycle all over..
so to break this down per your questions
#1 no you do not have to turn over any existing equipment you already have/had prior to the edge program
#2 the device you purchase in order to be placed on the EDGE pkg must be paid off within the 2 yr time frame and the payments are broken down by Verizon and this is WHAT is the determining factor of what the EDGE plan will cost you before the line access charge and data charge is included
#3 the number of devices under the EDGE pkg is ten.. you must have at least 1 that is a new device that you will be making payments on and the number of NEW devices you may have is determined by VERIZON but no more than 10 new total.. as it is the payments against the new device that qualifies the program
#4 yes any EDGE device (devices that were originally purchased in order to get the EDGE pkg) must be turned in to EDGE Up... whether paid up or with at least 75% paid off.. IF you do not wish to EDGE UP after the 2 yr time frame.. you may purchase NEW devices and go back under that standard plans Verizon has to offer...
#5 No company can lower sales tax,, the installments are configured against total cost.. which would be the device(s) taxes and any other surcharges
the last part.. the cost.. you are listing an up front cost .. I would check with VERIZON to see how much you qualify to do under installments,, as COSTCO can not do that,,the price they are quoting actual cost of them selling the devices...
so the EDGE is designed the allow payment installments,, that part no one here can estimate the monthly cost as we do not have access to your data nor can we set a total amount for Verizon to allow installments on.. that is why you need to contact them directly ... EDGE cost of monthly installment (according to amnt Verizon can set for you divided into payments) plus for every SMARTPHONE device you purchased you receive $15.00 off their line fee if you include at data plan that is at least 500mb to 8 GB and $25.00 per smartphone off line fee for data plans 10 GB or higher YOUR activation fee is waived for device purchased under the Edge plan...
THAN you can save even more by adding a calling plan,, like the MORE EVERYTHING plan which has the unlimited talk, text, hotspot/wifi, the data plan can be shared instead of a separate plan per phone . international message, the Cloud storage plan ..etc.. without know exactly what your devices are and how much Verizon will allow your acct to do under installments,, the total monthly NO ONE here is able to answer.. .but the monthly on the MORE EVERYTHING is $140 plus the discounted line fee per device.. the link will advise the devices allowed and the amount of each line fee
The MORE Everything Plan FAQs | Verizon Wireless
and placing the order through Verizon you will get $150 credit applied for EACH qualifying Smartphone you purchase under the EDGE plan...
again I apologize for not fully breaking it down this way as all of this is broken down in the original link I gave.. and if I have missed any thing,,, please,, let me know and I will be happy to go over it with you..
>> Edited by Verizon Moderator to comply with the Verizon Wireless Terms of Service << -
The issue about the ResultSet.TYPE_SCROLL_INSENSITIVE
my database is oracle ,the oracle charset is "us7ascii".and i save chinese charset in the database ,normally ,i get the data from the database ,use
Statement s =conn.createStatement();
then execute the sql, then use
new String (string.getBytes("iso-8859-1"),"gbk")
i can get the correct data.but if i use:
Statement s = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
still use:
new String (string.getBytes("iso-8859-1"),"gbk")
convert the encode,but i can't get the correct data ,the result is "?????" ,why ?rp0428 wrote:
Really? Please explain how that is possible.
The US7ASCII only uses 7 bits to represent each character so can only represent 128 characters; none of them are chinese.Perhaps the sleazy hack "new String(string.getBytes())" actually works to encode and decode characters between Unicode and 7-bit ASCII -- but I haven't got the energy to figure out how it might work. My response to this sort of question is "Configure Oracle with the right character set in the first place so you don't have to deal with it at the application level".
Maybe you are looking for
-
Is there any way to "Print book" with mixed version FM files?
Am fairly new to Framemaker and we all just upgraded to TCS and FM 9 from FM 7.2. After upgrade, when I went to "print book" and generate the postscript file, I found I had to re-save each FM file in the book to the current version before it would wo
-
How to check either my iPhone is manufactured in Indian or not?
I purchased an iPhone4 32 GB from my friend and i want to know that either this iPhone is Indian or not. Can any one tell me that is there any way to check this through IMEI number, Serial Number, iTunes or iCloud.
-
Create multiple paged pdf, ran out of room?
I'm trying to create a 19 page pdf in AI, but it will not let me. Is there some way to resize the canvas, or something? I need 19 letter sized pages but it won't let me create them. Thanks for any help
-
How to report answers without points?
Is it possible to report answers without adding points to a quiz? I am using Captivate 6. We have set up custom multiple choice questions rather than using the quiz templates. If I check the Include in Quiz option, and deselect Add to Total, I cannot
-
Company Security at specific hierarchy points
I need to enable company level security when users want to run a report at certain cost center hierarchy points. Does anyone know how/if this is possible? The company needs to be available to be run with lower level cost center hierarchy points and t