cancel
Showing results for 
Search instead for 
Did you mean: 

Error "Could not open/read file"

Former Member
0 Kudos
5,601

Hi everybody, I have developed a java application that requires a connection to DB. The DB that I use is Sybase on iAnywhere. My application runs on a PDA with Windows CE Version 5.00 and Creme Java platform.

When the device remains in standby for a long time (eg. for a night) the connection between the application and the database closes. My problem occurs when the application, once found that the connection is closed, try to create a new one.

When the application tries to create a new connection, iAnywhere starts, but after a few seconds a small window appears with the following error:

    Error
    Could not open / read file:
    ????????
    ++++?????????????
    ++++???????????
    ++++??????????
    ++++??????????????????


At the same time, the application returns me this exception:

    java.sql.SQLException: JZ006: Caught IOException: java.net.ConnectException: Syscall: Unable to Connect
        at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError ()
        at com.sybase.jdbc3.jdbc.ErrorMessage.raiseErrorCheckDead ()
        at com.sybase.jdbc3.tds.Tds.a ()
        at com.sybase.jdbc3.tds.Tds.a ()
        at com.sybase.jdbc3.tds.Tds.login ()
        at com.sybase.jdbc3.jdbc.SybConnection.a ()
        at com.sybase.jdbc3.jdbc.SybConnection.a ()
        at com.sybase.jdbc3.jdbc.SybConnection. <init> ()
        at com.sybase.jdbc3.jdbc.SybConnection. <init> ()
        at com.sybase.jdbc3.jdbc.SybDriver.connect ()
        at it.imolinfo.dao.DBHelper.myGetConnection ()
        at it.imolinfo.dao.DBHelper.myGetConnection ()
        at it.imolinfo.dao.DBHelper.myGetConnection ()
        at it.imolinfo.dao.DBHelper.myGetConnection ()
        at it.imolinfo.dao.DBHelper.myGetConnection ()
        at it.imolinfo.dao.DBHelper.init ()
        at it.imolinfo.dao.DBHelper.checkConnectionStatus ()
        at it.imolinfo.dao.OrdiniDAO.leggiRepartiPerEnte ()
        it.imolinfo.pages.Menu at $ 2.widgetSelected ()
        at org.eclipse.swt.widgets.TypedListener.handleEvent ()
        at org.eclipse.swt.widgets.EventTable.sendEvent ()
        at org.eclipse.swt.widgets.Widget.sendEvent ()
        at org.eclipse.swt.widgets.Display.runDeferredEvents ()
        at org.eclipse.swt.widgets.Display.readAndDispatch ()
        at main.MainMegaController.main ()
        at sun.misc.jar.main ()

Someone can help me on what could be the problem because the connection method that I use to reconnect the application is the same that works perfectly at the first connection?

My method of connection to the DB is as follows:

    String par = " \\"" + ConfigurationReader.SYBASE_EXE_PATH + "\\" -n " + nameDB +
                 " -x tcpip{PORT="+ ConfigurationReader.SYBASE_PORT +"} -ga " +
                 "\\"" + ConfigurationReader.SYBASE_PATH + "\\" ";
    Runtime.getRuntime().exec(new String [] {"cmd.exe", "/ C", "start"} + par);

    SybDriver sybDriver = (SybDriver) Class.forName (SYBASE_DRIVER). NewInstance ();

    SYBASE_PROPERTIES.put (SYBASE_USERNAME_PROPERTY, SYBASE_USERNAME);
    SYBASE_PROPERTIES.put (SYBASE_PASSWORD_PROPERTY, SYBASE_PASSWORD);
    SYBASE_PROPERTIES.put (SYBASE_DUC_PROPERTY, SYBASE_DUC);
    SYBASE_PROPERTIES.put (SYBASE_CHARSET_PROPERTY, SYBASE_CHARSET);

    URL + host + = SYBASE_URL SYBASE_PORT;
    MainMegaController.conn sybDriver.connect = (URL, SYBASE_PROPERTIES);
    MainMegaController.conn.setAutoCommit (false);

Which file refers iAnywhere when reporting the error "Could not open / read file"?

Thanks in advance for your help.

Regards,
Max

Accepted Solutions (0)

Answers (2)

Answers (2)

ian_mchardy
Advisor
Advisor

Note that using JConnect on Windows CE is not officially supported. But given that it seems to work for you with your VM, you could try connecting to the running server before exec a new one. Although your existing code may be OK because if you try to start a 2nd server on CE and one is already running, the 2nd server just closes.

Note that John mentions the client library automatically starting and stopping the server. That is not supported by JConnect, and the SQL Anywhere JDBC driver is not supported on Windows CE. So while you could do that from ODBC, OLEDB, ADO.NET or DBLib, you can't do that from JDBC. (Note JConnect is a driver designed for Sybase ASE that works with SQL Anywhere, while the SQL Anywhere JDBC driver is a different JDBC driver only for SQL Anywhere, and generally the SQL Anywhere JDBC driver is recommended - but neither are officially supported on Windows CE).

All that said, I don't have any idea why you are getting the error "Could not open / read file:". If you start a SQL Anywhere Server on a database on your device, then turn off your device and turn it on again, do you get an error?
What version of SQL Anywhere are you running (please include the build number)?

Former Member
0 Kudos

At the first connection I have never encountered any problems!
I use ASA9 (dbsrv9.exe), sorry but I have not found the build number.

MarkCulp
Participant
0 Kudos

FYI: Running "dbsrv9 -v" will tell you the build number

johnsmirnios
Participant

If you execute that same code each time you connect then I'd say you are trying to start a second server on the same file which won't work because the file is still in use by the first server. Unless you are using autostart, the server doesn't stop just because a connection went away. Instead of starting another server, just reconnect. Alternatively, provide all the necessary information to start the server in you connection parameters and then let the client libraries start the server for you as necessary. In that case, the database & server will go down when the last connection goes away.

Former Member
0 Kudos

I have to deal with both problems, that is, or should I reconnect to the server if the connection is closed or I have to reboot the server and reconnect at this when the server goes down.
In both cases, my application simply recognizes the connection as closed ... there is a unique way to manage both problems?

johnsmirnios
Participant
0 Kudos

As Ian suggested, you could try reconnecting to the server and, if that fails, try starting a new one then connecting to that.