public static Action<Action<SQLiteConnection>> AsWithConnection(this string DataSource, int Version = 3, bool ReadOnly = true) { //Console.WriteLine("AsWithConnection..."); return (y) => { //Console.WriteLine("AsWithConnection... invoke"); using (var c = DataSource.ToConnection(Version, ReadOnly)) { c.Open(); try { y(c); } catch (Exception ex) { var message = new { ex.Message, ex.StackTrace }.ToString(); Console.WriteLine("AsWithConnection... error: " + message.SkipUntilLastIfAny("Caused by:")); // The database file is locked throw new InvalidOperationException(message); } } }; }
public static Action<Action<SQLiteConnection>> xAsWithConnection(this SQLiteConnectionStringBuilder csb) { //Console.WriteLine("AsWithConnection..."); return y => { //Console.WriteLine("AsWithConnection... invoke"); //using (var c = new SQLiteCdataonnection(csb.ConnectionString)) //var c = new SQLiteConnection("Data Source=/StressData.s3db"); // X:\jsc.svn\examples\rewrite\Test\TestSQLiteMSIL\TestSQLiteMSIL\Class1.cs //java.lang.NullPointerException // at ScriptCoreLibJava.BCLImplementation.System.__String.Contains(__String.java:143) // at ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteConnection.Open(__SQLiteConnection.java:61) // at SQLiteWithDataGridView.Schema.XX._xAsWithConnection_b__0(XX.java:54) // ... 54 more //} //using (var c = new SQLiteConnection("Data Source=/StressData.s3db")) //using (var c = new SQLiteConnection(csb.ToString())) using (var c = new SQLiteConnection(csb.ConnectionString)) { c.Open(); try { y(c); } catch (Exception ex) { var message = new { ex.Message, ex.StackTrace }; //Console.WriteLine("AsWithConnection... error: " + message); //java //throw new InvalidOperationException(message.ToString()); // php throw new Exception(message.ToString()); } } }; }
public static Action<Action<SQLiteConnection>> xAsWithConnection(this string DataSource, int Version = 3) { //Console.WriteLine("AsWithConnection..."); return y => { //Console.WriteLine("AsWithConnection... invoke"); using (var c = DataSource.ToConnection(Version)) { c.BusyTimeout = 5000; c.Open(); try { y(c); } catch (Exception ex) { var message = new { ex.Message, ex.StackTrace }.ToString(); Console.WriteLine("AsWithConnection... error: " + new { ex }); throw new InvalidOperationException(message); } } }; }
public static Action<Action<SQLiteConnection>> xAsWithConnection(this SQLiteConnectionStringBuilder csb) { //Console.WriteLine("AsWithConnection..."); if (PointerSync.ListMode) { return y => { lock (synclock) { y(null); } }; } #region :memory: if (PointerSync.MemoryDataSource || PointerSync.PersistentConnection) { return y => { if (AsWithConnection_memory == null) { AsWithConnection_memory = new SQLiteConnection(new SQLiteConnectionStringBuilder { DataSource = PointerSync.MemoryDataSource ? // this wont work with XSQLite? ":memory:" : csb.DataSource }.ConnectionString); AsWithConnection_memory.Open(); } y(AsWithConnection_memory); }; } #endregion return y => { //Console.WriteLine("AsWithConnection... invoke"); using (var c = new SQLiteConnection(csb.ConnectionString)) { c.BusyTimeout = 1000; c.Open(); try { y(c); } catch (Exception ex) { var message = new { ex.Message, ex.StackTrace }; //Console.WriteLine("AsWithConnection... error: " + message); //java //throw new InvalidOperationException(message.ToString()); // php throw new Exception(message.ToString()); } } }; }
public static Action<Action<SQLiteConnection>> xAsWithConnection(this SQLiteConnectionStringBuilder csb) { //Console.WriteLine("AsWithConnection..."); return y => { //Console.WriteLine("AsWithConnection... invoke"); using (var c = new SQLiteConnection(csb.ConnectionString)) { c.Open(); try { y(c); } catch (Exception ex) { var message = new { ex.Message, ex.StackTrace }; //Console.WriteLine("AsWithConnection... error: " + message); //java //throw new InvalidOperationException(message.ToString()); // php throw new Exception(message.ToString()); } } }; }
public static Action<Action<SQLiteConnection>> AsWithConnection(this string DataSource, int Version = 3, bool ReadOnly = true) { //Console.WriteLine("AsWithConnection..."); return y => { //Console.WriteLine("AsWithConnection... invoke"); using (var c = DataSource.ToConnection(Version, ReadOnly)) { try { c.Open(); //__ConsoleToDatabaseWriter.InternalWriteLine("AsWithConnection open"); y(c); //__ConsoleToDatabaseWriter.InternalWriteLine("AsWithConnection close"); c.Close(); } catch (Exception ex) { __ConsoleToDatabaseWriter.InternalWriteLine("AsWithConnection... error: "); Thread.Sleep(5000); var message = new { ex.Message, ex.StackTrace }; //Console.WriteLine("AsWithConnection... error: " + message); __ConsoleToDatabaseWriter.InternalWriteLine(" " + message); // Caused by: java.lang.StackOverflowError //at java.io.Win32FileSystem.canonicalize(Unknown Source) //at java.io.File.getCanonicalPath(Unknown Source) //at sun.security.provider.PolicyFile.canonPath(Unknown Source) //at java.io.FilePermission$1.run(Unknown Source) //at java.io.FilePermission$1.run(Unknown Source) //at java.security.AccessController.doPrivileged(Native Method) //at java.io.FilePermission.init(Unknown Source) //at java.io.FilePermission.<init>(Unknown Source) //at java.lang.SecurityManager.checkRead(Unknown Source) //at java.io.File.exists(Unknown Source) //at java.io.Win32FileSystem.canonicalize(Unknown Source) //at java.io.File.getCanonicalPath(Unknown Source) //at sun.security.provider.PolicyFile.canonPath(Unknown Source) //at java.io.FilePermission$1.run(Unknown Source) //at java.io.FilePermission$1.run(Unknown Source) //at java.security.AccessController.doPrivileged(Native Method) //at java.io.FilePermission.init(Unknown Source) //at java.io.FilePermission.<init>(Unknown Source) //at java.lang.SecurityManager.checkRead(Unknown Source) //at java.io.File.exists(Unknown Source) //at sun.misc.URLClassPath$FileLoader.getResource(Unknown Source) //at sun.misc.URLClassPath.getResource(Unknown Source) //at java.net.URLClassLoader$1.run(Unknown Source) //at java.security.AccessController.doPrivileged(Native Method) //at java.net.URLClassLoader.findClass(Unknown Source) //at java.lang.ClassLoader.loadClass(Unknown Source) //at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:213) //at java.lang.ClassLoader.loadClass(Unknown Source) //at ConsoleByCookie.Schema.XX___c__DisplayClass1._AsWithConnection_b__0(XX___c__DisplayClass1.java:43) Thread.Sleep(10000); //java //throw new InvalidOperationException(message.ToString()); // php throw new Exception(message.ToString()); } } }; }