Archived
This forum has been archived. Please start a new discussion on GitHub.
How can I send 1000 books to the server.
Hallo Everybody,
I am using the provided example (from Demos Ice 3.4.2 ) of the Server which connects to a MySQL database and the Android app wich can save books in the database.
Now I start a service that runs in the background. The thread reads the books from a local database and then calls the save method called also when the user saves manualy a book on the androiddevice.
After 4 books were saved the app crashes. Is it because the callback? In the application providede with Ice 3.4.2 there is a Client who saves 30 books. I want to mimic exactly that behaiviour with the Android app.
How can I adapt the android app provided with the Ice 3.4.2 to save books until I stop the Sevice?
Regards,
Paul
I am using the provided example (from Demos Ice 3.4.2 ) of the Server which connects to a MySQL database and the Android app wich can save books in the database.
Now I start a service that runs in the background. The thread reads the books from a local database and then calls the save method called also when the user saves manualy a book on the androiddevice.
After 4 books were saved the app crashes. Is it because the callback? In the application providede with Ice 3.4.2 there is a Client who saves 30 books. I want to mimic exactly that behaiviour with the Android app.
How can I adapt the android app provided with the Ice 3.4.2 to save books until I stop the Sevice?
Regards,
Paul
0
Comments
-
Hi Paul,
Without see the code and stack of the crash is difficult for us to help.there is a Client who saves 30 books. I want to mimic exactly that behaiviour with the Android app.
The code for this client is included in the demo, the client just call the Library createBook operation to add each new book.0 -
The Log files aand the code
Hy,
//this method is called periodically by the service
private void doServiceWork()
{
//do something wotever you want
//like reading file or getting data from network
addEvent(getOutputX()+" "+getOutputY()+" "+getOutputZ()+" ");
// Log.i(getClass().getSimpleName(), "from periodic task...");
Log.d("from dowork","ss");
//the save operation that send data to the server, it is basicaly the same save as in the demo
save();
}
//it is this
private void save()
{
List<String> authors = new ArrayList<String>();
/* for(View authorView : _authorEntries)
{
EditText auth = (EditText)authorView.findViewById(R.id.author);
String a = auth.getText().toString().trim();
if(a.length() > 0)
{
authors.add(a);
}
}*/
// datele din cele 2 tabele sunt diferite pt ca contin date diferite
cal = Calendar.getInstance();
authors.add(Long.toString(cal.getTimeInMillis()) + 1); //hours
description.authors = authors;
authors.clear();
// aici pot sa creez un string despartit de spati care contine toate informatile
//pt ambele tabele datele sa fie continute in stringul title
//_desc.title = _title.getText().toString().trim();
String speech = "Four score and seven years ago we succeded";
description.title = speech.trim();
description.isbn = Long.toString(cal.getTimeInMillis() + 1);//hours
if(!controller.saveBook(description))
{
finish();
}
}
//the saveBook(desciption); method is the same like in the Demo
//this method is in the class public abstract class Callback_Library_createBook extends Ice.TwowayCallback from the Demo. It was automaticaly generated
public final void __completed(Ice.AsyncResult __result)
{
LibraryPrx __proxy = (LibraryPrx)__result.getProxy();
BookPrx __ret = null;
try
{
// __ret = __proxy.end_createBook(__result);
//this is here my intervention
__ret = __proxy.end_createBook(null);
}
catch(Ice.LocalException __ex)
{
exception(__ex);
return;
} catch (BookExistsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response(__ret);
}
At this moment I succed to save 200 records after I get this error.
How i get read of this?
I think the solution is in this callback.
In the client that writes 30 books it is instaled a setInterruptHook:
public int
run(String[] args)
{
if(args.length > 1)
{
System.err.println("Usage: " + appName() + " [file]");
return 1;
}
//
// Since this is an interactive demo we want to clear the
// Application installed interrupt callback and install our
// own shutdown hook.
//
setInterruptHook(new ShutdownHook());
return RunParser.runParser(appName(), args, communicator());
}
//remark
12-06 20:01:32.245: WARN/System.err(11295): java.lang.IllegalArgumentException: AsyncResult == null
12-06 20:01:32.249: WARN/System.err(11295): at Ice.AsyncResult.__check(AsyncResult.java:366)
12-06 20:01:32.249: WARN/System.err(11295): at Ice.AsyncResult.__check(AsyncResult.java:331)
12-06 20:01:32.249: WARN/System.err(11295): at Demo.LibraryPrxHelper.end_createBook(LibraryPrxHelper.java:202)
12-06 20:01:32.253: WARN/System.err(11295): at Demo.Callback_Library_createBook.__completed(Callback_Library_createBook.java:62)
12-06 20:01:32.253: WARN/System.err(11295): at Ice.AsyncResult.__response(AsyncResult.java:386)
12-06 20:01:32.257: WARN/System.err(11295): at IceInternal.OutgoingAsync.__finished(OutgoingAsync.java:347)
12-06 20:01:32.257: WARN/System.err(11295): at Ice.ConnectionI.dispatch(ConnectionI.java:1198)
12-06 20:01:32.257: WARN/System.err(11295): at Ice.ConnectionI.message(ConnectionI.java:1163)
12-06 20:01:32.257: WARN/System.err(11295): at IceInternal.ThreadPool.run(ThreadPool.java:302)
12-06 20:01:32.257: WARN/System.err(11295): at IceInternal.ThreadPool.access$300(ThreadPool.java:12)
12-06 20:01:32.261: WARN/System.err(11295): at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:643)
12-06 20:01:32.261: WARN/System.err(11295): at java.lang.Thread.run(Thread.java:1096)
this is my main error I think and I think it is there because I rewriten the contence of the calback method to create a book but with the null object everytime
How can I achieve the same efect in my application, like the simplw Java Client that writes 30 books without crashing?
So that it is not crashing or enters in this state that it can not longer achieve a connection?
Regards
Paul0 -
Hi Paul,
//this is here my intervention __ret = __proxy.end_createBook(null);
You must not edit the generated code, passing an null AsyncResult is causing the exceptions.
Form your Android log12-06 20:01:32.320: WARN/System.err(11295): -! 06.12.11 20:01:32:317 warning: Ice.ThreadPool.Client-0: exception raised by AMI callback: 12-06 20:01:32.324: WARN/System.err(11295): java.lang.IllegalArgumentException: AsyncResult == null 12-06 20:01:32.324: WARN/System.err(11295): at Ice.AsyncResult.__check(AsyncResult.java:366) 12-06 20:01:32.324: WARN/System.err(11295): at Ice.AsyncResult.__check(AsyncResult.java:331) 12-06 20:01:32.324: WARN/System.err(11295): at Demo.LibraryPrxHelper.end_createBook(LibraryPrxHelper.java:202) 12-06 20:01:32.327: WARN/System.err(11295): at Demo.Callback_Library_createBook.__completed(Callback_Library_createBook.java:62) 12-06 20:01:32.327: WARN/System.err(11295): at Ice.AsyncResult.__exception(AsyncResult.java:261) 12-06 20:01:32.331: WARN/System.err(11295): at IceInternal.OutgoingAsync.__finished(OutgoingAsync.java:168) 12-06 20:01:32.331: WARN/System.err(11295): at IceInternal.OutgoingAsync.__finished(OutgoingAsync.java:342) 12-06 20:01:32.331: WARN/System.err(11295): at Ice.ConnectionI.dispatch(ConnectionI.java:1198) 12-06 20:01:32.331: WARN/System.err(11295): at Ice.ConnectionI.message(ConnectionI.java:1163) 12-06 20:01:32.335: WARN/System.err(11295): at IceInternal.ThreadPool.run(ThreadPool.java:302) 12-06 20:01:32.335: WARN/System.err(11295): at IceInternal.ThreadPool.access$300(ThreadPool.java:12) 12-06 20:01:32.335: WARN/System.err(11295): at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:643) 12-06 20:01:32.339: WARN/System.err(11295): at java.lang.Thread.run(Thread.java:1096)
If you look at AsyncResult.java line 366protected static void __check(AsyncResult r, String operation) { if(r == null) { throw new IllegalArgumentException("AsyncResult == null"); } else if(r.getOperation() != operation) // Do NOT use equals() here - we are comparing reference equality { throw new IllegalArgumentException("Incorrect operation for end_" + operation + " method: " + r.getOperation()); } }
So the exception is expected when a null AsyncResult is used. What exception do you get with the unmodified generated code?0 -
In your server log i see
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack at oracle.net.ns.NSProtocol.connect(NSProtocol.java:395) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
If you are trying to use a MYSQL database you should use the MySQL driver, not oracle driver as described in the demo, if you are connecting to an Oracle Database you must look why the connection with it fails, but that is an Oracle issue not an Ice issue.0 -
If I do not change the generated code
Hy,
If I do not change the generated code.
This is the output of the Java server from the Example present in the Demos.
I have the following . As you can see it is a repetitive output. Because It writes data in 3 tables.-- 12/7/11 18:01:42:123 demo.Database.library.Server: ConnectionPool: establishing new database connection con established con established con established con established demo.Database.library.Server: ConnectionPool: returning connection: oracle.jdbc.driver.T4CConnection@375e293a 0/5 remaining demo.Database.library.Server: SQLRequestContext: create new context: library.SQLRequestContext@62c8769b thread: Thread[Ice.ThreadPool.Server-6,5,main]: connection: oracle.jdbc.driver.T4CConnection@375e293a demo.Database.library.Server: SQLRequestContext: commit context: library.SQLRequestContext@548997d1 -- 12/7/11 18:01:42:680 demo.Database.library.Server: Protocol: sending reply message type = 2 (reply) compression status = 0 (not compressed; do not compress response, if any) message size = 162 request id = 7 reply status = 0 (ok) -- 12/7/11 18:01:42:680 demo.Database.library.Server: Protocol: received request message type = 0 (request) compression status = 0 (not compressed; do not compress response, if any) message size = 134 request id = 12 identity = a4794778-9c73-434d-b806-c1473ed3e1bc facet = operation = createBook mode = 0 (normal) context = -! 12/7/11 18:01:42:781 demo.Database.library.Server: warning: Ice.ThreadPool.Server-9: ConnectionPool: lost connection to database: java.sql.SQLSyntaxErrorException: ORA-00923: FROM keyword not found where expected at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396) at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207) at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:884) at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1167) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1289) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628) at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493) at library.ConnectionPool.acquire(ConnectionPool.java:72) at library.SQLRequestContext.<init>(SQLRequestContext.java:77) at library.DispatchInterceptorI.dispatch(DispatchInterceptorI.java:21) at Ice.DispatchInterceptor.__dispatch(DispatchInterceptor.java:43) at IceInternal.Incoming.invoke(Incoming.java:159) at Ice.ConnectionI.invokeAll(ConnectionI.java:2357) at Ice.ConnectionI.dispatch(ConnectionI.java:1208) at Ice.ConnectionI.message(ConnectionI.java:1163) at IceInternal.ThreadPool.run(ThreadPool.java:302) at IceInternal.ThreadPool.access$300(ThreadPool.java:12) at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:643) at java.lang.Thread.run(Unknown Source) -- 12/7/11 18:01:42:781 demo.Database.library.Server: ConnectionPool: establishing new database connection con established con established con established con established -- 12/7/11 18:01:43:241 demo.Database.library.Server: ConnectionPool: returning connection: oracle.jdbc.driver.T4CConnection@4c272961 0/5 remaining -- 12/7/11 18:01:43:241 demo.Database.library.Server: SQLRequestContext: create new context: library.SQLRequestContext@32dfcb47 thread: Thread[Ice.ThreadPool.Server-9,5,main]: connection: oracle.jdbc.driver.T4CConnection@4c272961 con established con established con established con established con established -- 12/7/11 18:01:43:790 demo.Database.library.Server: SQLRequestContext: commit context: library.SQLRequestContext@61f1680f -- 12/7/11 18:01:43:790 demo.Database.library.Server: Protocol: sending reply message type = 2 (reply) compression status = 0 (not compressed; do not compress response, if any) message size = 162 request id = 8 reply status = 0 (ok) -- 12/7/11 18:01:43:791 demo.Database.library.Server: Protocol: received request message type = 0 (request) compression status = 0 (not compressed; do not compress response, if any) message size = 134 request id = 13 identity = a4794778-9c73-434d-b806-c1473ed3e1bc facet = operation = createBook mode = 0 (normal) context = -! 12/7/11 18:01:43:886 demo.Database.library.Server: warning: Ice.ThreadPool.Server-1: ConnectionPool: lost connection to database: java.sql.SQLSyntaxErrorException: ORA-00923: FROM keyword not found where expected
To the server I connect via my addBook app which is the same app as in the Demos.
Now with the unchanged stub code as you sugested to my I have the outputs in the LogCat console from android. The app writes 3 or 4 records in the tables and the crashes. In the app I get. Ice.UnkonwnException exception=" ".The server application is running and I do not have to restart the server. i see that I have an Array out of bounds but I can not figure it out why?
In the FileScannerService i have the service class wich runs the periodical doWork() method.12-07 17:57:30.265: I/Zygote(17415): Zygote: pid 17415 has INTERNET permission, then set capability for CAP_NET_RAW(13) 12-07 17:57:34.741: D/dalvikvm(17415): GC_EXTERNAL_ALLOC freed 13287 objects / 524840 bytes in 34ms 12-07 17:57:43.569: I/dalvikvm(17415): Total arena pages for JIT: 11 12-07 17:59:07.218: W/KeyCharacterMap(17415): No keyboard for id 0 12-07 17:59:07.218: W/KeyCharacterMap(17415): Using default keymap: /system/usr/keychars/qwerty.kcm.bin 12-07 17:59:26.527: E/SensorManager(17415): ####### akmd2 started!!! 12-07 17:59:26.527: E/SensorManager(17415): registerListener 1:BMA150 delay:120 12-07 17:59:26.534: E/SensorManager(17415): =======>>>Sensor Thread RUNNING <<<======== 12-07 17:59:26.573: I/FileScannerService(17415): FileScannerService Timer started.... 12-07 17:59:26.612: W/Sensors(17415): Reader thread open Accelerometer = 51 12-07 17:59:26.648: D/from dowork(17415): ss 12-07 17:59:27.370: I/dalvikvm(17415): Jit: resizing JitTable from 4096 to 8192 12-07 17:59:27.589: D/from dowork(17415): ss 12-07 17:59:31.898: W/dalvikvm(17415): threadid=11: thread exiting with uncaught exception (group=0x4001d7d0) 12-07 17:59:31.901: E/AndroidRuntime(17415): FATAL EXCEPTION: Timer-0 12-07 17:59:31.901: E/AndroidRuntime(17415): java.lang.ArrayIndexOutOfBoundsException 12-07 17:59:31.901: E/AndroidRuntime(17415): at java.util.ArrayList.get(ArrayList.java:313) 12-07 17:59:31.901: E/AndroidRuntime(17415): at com.paul.android.tutorial.controller.QueryController.saveBook(QueryController.java:408) 12-07 17:59:31.901: E/AndroidRuntime(17415): at com.paul.android.tutorial.FileScannerService.save(FileScannerService.java:553) 12-07 17:59:31.901: E/AndroidRuntime(17415): at com.paul.android.tutorial.FileScannerService.doServiceWork(FileScannerService.java:182) 12-07 17:59:31.901: E/AndroidRuntime(17415): at com.paul.android.tutorial.FileScannerService.access$0(FileScannerService.java:172) 12-07 17:59:31.901: E/AndroidRuntime(17415): at com.paul.android.tutorial.FileScannerService$1.run(FileScannerService.java:152) 12-07 17:59:31.901: E/AndroidRuntime(17415): at java.util.Timer$TimerImpl.run(Timer.java:289) 12-07 17:59:47.984: I/Zygote(17520): Zygote: pid 17520 has INTERNET permission, then set capability for CAP_NET_RAW(13) 12-07 17:59:48.050: D/SensorManager(17520): ====>>>>>Num Sensor: 1 12-07 17:59:48.069: W/SensorManager(17520): Delay Candidate Listener 0 Sensor:1 delay:120 12-07 17:59:48.069: I/Sensors(17520): sensors_data_delay handle=1 delay=120 mMinDelay=120 12-07 17:59:48.069: E/SensorManager(17520): registerListener 0:AK8973 Compass delay:120 12-07 17:59:48.073: W/SensorManager(17520): Delay Candidate Listener 0 Sensor:0 delay:120 12-07 17:59:48.073: I/Sensors(17520): sensors_data_delay handle=0 delay=120 mMinDelay=120 12-07 17:59:48.073: I/FileScannerService(17520): FileScannerService Timer started.... 12-07 17:59:48.093: W/Sensors(17520): Reader thread open Accelerometer = 36 12-07 17:59:48.136: D/from dowork(17520): ss 12-07 17:59:48.136: W/dalvikvm(17520): threadid=8: thread exiting with uncaught exception (group=0x4001d7d0) 12-07 17:59:48.136: E/AndroidRuntime(17520): FATAL EXCEPTION: Timer-0 12-07 17:59:48.136: E/AndroidRuntime(17520): java.lang.NullPointerException 12-07 17:59:48.136: E/AndroidRuntime(17520): at com.paul.android.tutorial.FileScannerService.save(FileScannerService.java:542) 12-07 17:59:48.136: E/AndroidRuntime(17520): at com.paul.android.tutorial.FileScannerService.doServiceWork(FileScannerService.java:182) 12-07 17:59:48.136: E/AndroidRuntime(17520): at com.paul.android.tutorial.FileScannerService.access$0(FileScannerService.java:172) 12-07 17:59:48.136: E/AndroidRuntime(17520): at com.paul.android.tutorial.FileScannerService$1.run(FileScannerService.java:152) 12-07 17:59:48.136: E/AndroidRuntime(17520): at java.util.Timer$TimerImpl.run(Timer.java:289) 12-07 17:59:58.714: I/Process(17520): Sending signal. PID: 17520 SIG: 9
0 -
This is my method who writes data in the 3 tables.
public BookPrx createBook(String isbn, String title, java.util.List<String> authors, Ice.Current current) throws BookExistsException { SQLRequestContext context = SQLRequestContext.getCurrentContext(); assert context != null; /*st = new StringTokenizer(title); while (st.hasMoreTokens()) { // stmt.setString(i2, st.nextToken().t); }*/ // s.execute("Insert into MOBTEST.BOOKS (ID,ISBN,TITLE,RENTER_ID) values (1,null,'marius',null)"); // s.close(); // connection.close(); try { connection = getConnection(); stmt = connection.prepareStatement("SELECT * FROM locations WHERE time = ?"); stmt.setString(1, isbn); java.sql.ResultSet rs = stmt.executeQuery(); if(rs.next()) { throw new BookExistsException(); } connection.close(); // // First convert the authors string to an id set. // connection = getConnection(); java.util.List<Integer> authIds = new java.util.LinkedList<Integer>(); for(String author : authors) { Integer id; stmt = connection.prepareStatement("SELECT * FROM headings WHERE time = ?"); stmt.setString(1, author); rs = stmt.executeQuery(); if(rs.next()) { // If there is a result, then the database // already contains this author. // id = rs.getInt(1); assert !rs.next(); } else { // Otherwise, create a new author record. stmt = connection.prepareStatement("INSERT INTO headings (time,geo,mag,x,y,z,originaltrackid,accuracy) VALUES(?, ?, ?, ?, ?, ?, ?, ?)",java.sql.Statement.RETURN_GENERATED_KEYS); stmt.setString(1, author); stmt.setString(2, author); stmt.setString(3, author); stmt.setString(4, author); stmt.setString(5, author); stmt.setString(6, author); stmt.setString(7, author); stmt.setString(8, author); int count = stmt.executeUpdate(); assert count == 1; rs = stmt.getGeneratedKeys(); boolean next = rs.next(); assert next; // id = rs.getInt(1); } // Add the new id to the list of ids. authIds.add(1); } connection.close(); //write into headings connection = getConnection(); // Otherwise, create a new author record. stmt = connection.prepareStatement("INSERT INTO headings (time,geo,mag,x,y,z,originaltrackid,accuracy) VALUES(?, ?, ?, ?, ?, ?, ?, ?)",java.sql.Statement.RETURN_GENERATED_KEYS); stmt.setString(1, title); stmt.setString(2, title); stmt.setString(3, title); stmt.setString(4, title); stmt.setString(5, title); stmt.setString(6, title); stmt.setString(7, title); stmt.setString(8, title); int count = stmt.executeUpdate(); assert count == 1; rs = stmt.getGeneratedKeys(); boolean next = rs.next(); assert next; // Integer bookId = rs.getInt(1); connection.close(); // Create the new book. connection = getConnection(); stmt = connection.prepareStatement("INSERT INTO locations (time, latitude,longitude,altitude,hdop,vdop,speed,originaltrackid,course) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", java.sql.Statement.RETURN_GENERATED_KEYS); stmt.setString(1, isbn); stmt.setString(2, title.subSequence(0, 4).toString()); stmt.setString(3, (String) title.subSequence(5, 10)); stmt.setString(4, title); stmt.setString(5, title); stmt.setString(6, title); stmt.setString(7, title); stmt.setString(8, title); stmt.setString(9, title); //alternative int count2 = stmt.executeUpdate(); assert count2 == 1; rs = stmt.getGeneratedKeys(); boolean next2 = rs.next(); assert next2; // Integer bookId = rs.getInt(1); connection.close(); connection = getConnection(); // Create new authors_books records. stmt = connection.prepareStatement("INSERT INTO accelerations (devicetype, trackid, time, x, y, z, rotx, roty, rotz, tmp, originaltrackid) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",java.sql.Statement.RETURN_GENERATED_KEYS); stmt.setString(1, isbn); stmt.setString(2, isbn); stmt.setString(3, isbn); stmt.setString(4, isbn); stmt.setString(5, isbn); stmt.setString(6, isbn); stmt.setString(7, isbn); stmt.setString(8, isbn); stmt.setString(9, isbn); stmt.setString(10, isbn); stmt.setString(11, isbn); count = stmt.executeUpdate(); assert count == 1; rs = stmt.getGeneratedKeys(); boolean next3 = rs.next(); assert next3; connection.close(); return BookPrxHelper.uncheckedCast(current.adapter.createProxy(BookI.createIdentity(1))); } catch(java.sql.SQLException e) { JDBCException ex = new JDBCException(); ex.initCause(e); throw ex; } }
I think i should not open an connection everytime I am write something in a table.0 -
The getConnection() method.
public Connection getConnection(){ try { // Load the JDBC driver Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); connection = DriverManager.getConnection("jdbc:oracle:thin:mobtest@//129.187.64.237:1521/orcl", "lalalalalala", "lalalala"); System.out.println("con established"); } catch (ClassNotFoundException e) { // Could not find the database driver } catch (SQLException e) { // Could not connect to the database } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } return connection; }
0 -
If I used the modifier code with.
LibraryPrx __proxy = (LibraryPrx)__result.getProxy(); BookPrx __ret = null; try { // __ret = __proxy.end_createBook(__result); __ret = __proxy.end_createBook(null); } catch(Ice.LocalException __ex) { exception(__ex); return; } catch (BookExistsException e) { // TODO Auto-generated catch block e.printStackTrace(); } response(__ret);
I get in the Server console after I succesfully writen some 170 records +/- in each Table.(The value is not the same for each table, also a ? do not know why).at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:643) at java.lang.Thread.run(Unknown Source) Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack at oracle.net.ns.NSProtocol.connect(NSProtocol.java:395) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320) ... 18 more -- 12/7/11 18:34:10:663 demo.Database.library.Server: ConnectionPool: establishing new database connection -! 12/7/11 18:34:10:790 demo.Database.library.Server: warning: Ice.ThreadPool.Server-14: ConnectionPool: database connection failed: java.sql.SQLException: Listener refused the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:458) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at library.ConnectionPool.acquire(ConnectionPool.java:97) at library.SQLRequestContext.<init>(SQLRequestContext.java:77) at library.DispatchInterceptorI.dispatch(DispatchInterceptorI.java:21) at Ice.DispatchInterceptor.__dispatch(DispatchInterceptor.java:43) at IceInternal.Incoming.invoke(Incoming.java:159) at Ice.ConnectionI.invokeAll(ConnectionI.java:2357) at Ice.ConnectionI.dispatch(ConnectionI.java:1208) at Ice.ConnectionI.message(ConnectionI.java:1163) at IceInternal.ThreadPool.run(ThreadPool.java:302) at IceInternal.ThreadPool.access$300(ThreadPool.java:12) at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:643) at java.lang.Thread.run(Unknown Source) Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack at oracle.net.ns.NSProtocol.connect(NSProtocol.java:395) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320) ... 18 more -- 12/7/11 18:34:10:790 demo.Database.library.Server: ConnectionPool: establishing new database connection -! 12/7/11 18:34:10:887 demo.Database.library.Server: warning: Ice.ThreadPool.Server-14: ConnectionPool: database connection failed: java.sql.SQLException: Listener refused the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:458) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at library.ConnectionPool.acquire(ConnectionPool.java:97) at library.SQLRequestContext.<init>(SQLRequestContext.java:77) at library.DispatchInterceptorI.dispatch(DispatchInterceptorI.java:21) at Ice.DispatchInterceptor.__dispatch(DispatchInterceptor.java:43) at IceInternal.Incoming.invoke(Incoming.java:159) at Ice.ConnectionI.invokeAll(ConnectionI.java:2357) at Ice.ConnectionI.dispatch(ConnectionI.java:1208) at Ice.ConnectionI.message(ConnectionI.java:1163) at IceInternal.ThreadPool.run(ThreadPool.java:302) at IceInternal.ThreadPool.access$300(ThreadPool.java:12) at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:643) at java.lang.Thread.run(Unknown Source) Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack at oracle.net.ns.NSProtocol.connect(NSProtocol.java:395) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320) ... 18 more -- 12/7/11 18:34:10:887 demo.Database.library.Server: ConnectionPool: establishing new database connection -! 12/7/11 18:34:10:991 demo.Database.library.Server: warning: Ice.ThreadPool.Server-14: ConnectionPool: database connection failed: java.sql.SQLException: Listener refused the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:458) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at library.ConnectionPool.acquire(ConnectionPool.java:97) at library.SQLRequestContext.<init>(SQLRequestContext.java:77) at library.DispatchInterceptorI.dispatch(DispatchInterceptorI.java:21) at Ice.DispatchInterceptor.__dispatch(DispatchInterceptor.java:43) at IceInternal.Incoming.invoke(Incoming.java:159) at Ice.ConnectionI.invokeAll(ConnectionI.java:2357) at Ice.ConnectionI.dispatch(ConnectionI.java:1208) at Ice.ConnectionI.message(ConnectionI.java:1163) at IceInternal.ThreadPool.run(ThreadPool.java:302) at IceInternal.ThreadPool.access$300(ThreadPool.java:12) at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:643) at java.lang.Thread.run(Unknown Source) Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack at oracle.net.ns.NSProtocol.connect(NSProtocol.java:395) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320) ... 18 more -- 12/7/11 18:34:10:992 demo.Database.library.Server: ConnectionPool: establishing new database connection -! 12/7/11 18:34:11:088 demo.Database.library.Server: warning: Ice.ThreadPool.Server-14: ConnectionPool: database connection failed: java.sql.SQLException: Listener refused the connection with the following error: ORA-12516, TNS:listener could not find available handler with matching protocol stack
And I observe that I new connection with the database could not be established. Because
As you can see the "con established" string is no longer between this output, wich is displayed if a database connection was succesfully established. I have to say that I use the ojdbc6.jar driver. The database is a Oracle 10g.0 -
Paul,
The problem you're having with your application appears totally unrelated to Ice--you create lots of JDBC connections to your Oracle 10g database and at some point the connection establishment fails. Ice is not involved at all in this.
You should probably pool / reuse these connections, and not create and close connections all the time; how to do this properly is unrelated to Ice. You may want to try an Oracle or JDBC forum instead.
Best regards,
Bernard0 -
The Tomcat JDBC Connection Pool is a good choice. You can try it.0