Hello David,
here my test code:
// share with readonly access
File fileOnReadOnlyShare = new File ("I:\\Programme\\SEU_Test\\Tools\
\ProcMan\\ConfigDir\\ProcManMsgDB.db3");
// file and dir writable
File fileOnReadWriteShare = new File ("C:\\temp\\tt\
\ProcManTestDB.db3");
try
{
System.out.println("fileOnReadOnlyShare.createNewFile() : " +
fileOnReadOnlyShare.createNewFile());
}
catch(IOException ioex)
{
System.out.println(ioex.getMessage() + " --
fileOnReadOnlyShare.createNewFile() gives IO Error!");
System.out.println("fileOnReadOnlyShare.exists() : " +
fileOnReadOnlyShare.exists());
}
System.out.println("fileOnReadWriteShare.createNewFile() : " +
fileOnReadWriteShare.createNewFile());
#######################################################################
Output
Zugriff verweigert -- fileOnReadOnlyShare.createNewFile() gives IO
Error!
fileOnReadOnlyShare.exists() : true
fileOnReadWriteShare.createNewFile() : false
So You're right, it seem to be a bug in the JDK. I have submitted it
already. But would it be possible to check the exists() function of
the file first in the constructor of the Conn class? This will solve
my problem. When is the next release planed?
Thanks in advance
Frank
On Feb 12, 5:12 pm, "David Crawshaw" <[EMAIL PROTECTED]> wrote:
> > The statement file.createNewFile() fails on a read only share. Since
> > the file is there it should be possible to access it.
>
> That's interesting, the Java spec I was following states that createNewFile():
>
> "Atomically creates a new, empty file named by this abstract
> pathname if and only if a file with this name does not yet exist."
>
> So if the file exists on the read-only share, the call to
> createNewFile() should do nothing and return false, and SQLite will
> proceed to open it for reading. Is this not the behaviour your seeing?
> If not, try the following:
>
> - if (file.createNewFile()) file.delete();
> + if (!file.exists() && file.createNewFile()) file.delete();
>
> If this works, you've found a bug in the JDK.
>
> d.
--~--~---------~--~----~------------~-------~--~----~
Mailing List: http://groups.google.com/group/sqlitejdbc?hl=en
To unsubscribe, send email to [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---