コード例 #1
0
        private void InternalCreateStatement()
        {
            // Z:\jsc.svn\examples\javascript\LINQ\test\auto\TestSelect\TestXMySQLCLRInsert\Program.cs
            // X:\jsc.svn\examples\java\appengine\Test\TestThreadManager\TestThreadManager\ApplicationWebService.cs

            //throw null;

            // tested by?

            if (this.InternalStatement != null)
            {
                return;
            }

            var sql = this.InternalCommandText;

            //Console.WriteLine("enter InternalCreateStatement" + new { sql });
            try
            {
                // http://www.javaworld.com/javaworld/jw-04-2007/jw-04-jdbc.html
                if (this.Parameters.InternalParameters.Count > 0)
                {
                    //Console.WriteLine("we have InternalParameters for " + sql);

                    var parameters = this.Parameters.InternalParameters;

                    var index =
                        from p in parameters
                        from i in this.CommandText.GetIndecies(p.ParameterName)
                        orderby i
                        select new { p, i };


                    // did we break it?
                    foreach (var p in parameters.ToArray())
                    {
                        // java seems to like indexed parameters instead
                        sql = sql.Replace(p.ParameterName, "?");
                    }

                    this.InternalPreparedStatement = this.c.InternalConnection.prepareStatement(sql);

                    var c = 0;
                    foreach (var item in index)
                    {
                        c++;

                        // X:\jsc.svn\examples\java\appengine\Test\TestThreadManager\TestThreadManager\ApplicationWebService.cs
                        // Z:\jsc.svn\examples\java\Test\TestIsinst\TestIsinst\Class1.cs

                        if (item.p.Value == null)
                        {
                            this.InternalPreparedStatement.setObject(c, null);
                        }
                        else if (item.p.Value is int)
                        {
                            this.InternalPreparedStatement.setInt(c, (int)item.p.Value);
                        }
                        else if (item.p.Value is long)
                        {
                            this.InternalPreparedStatement.setLong(c, (long)item.p.Value);
                        }
                        else if (item.p.Value is double)
                        {
                            // X:\jsc.svn\examples\javascript\forms\Test\TestSQLiteGroupBy\TestSQLiteGroupBy\ApplicationWebService.cs
                            this.InternalPreparedStatement.setDouble(c, (double)item.p.Value);
                        }
                        else if (item.p.Value is string)
                        {
                            this.InternalPreparedStatement.setString(c, (string)item.p.Value);
                        }
                        else if (item.p.Value is byte[])
                        {
                            this.InternalPreparedStatement.setBytes(c, (sbyte[])item.p.Value);
                        }
                        else
                        {
                            //Caused by: java.lang.RuntimeException: InternalCreateStatement, what to do with this? { CommandText = insert into Table1 (ContentValue, ContentBytes) values (@ContentValue /* text */, @ContentBytes), type = ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteParameter, isBytes = true, bytes = [B, eqBytes = true, item = { p = ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteParameter@1908330, i = 82 } }

                            // http://docs.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#setBytes(int, byte[])

                            //Caused by: java.lang.RuntimeException: InternalCreateStatement, what to do with this?
                            // { CommandText = insert into Table1 (ContentValue, ContentBytes) values (@ContentValue /* text */, @ContentBytes),
                            // item = { p = ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteParameter@47f703, i = 82 },
                            // type = __AnonymousTypes__ScriptCoreLibJava.__f__AnonymousType1_2 }

                            //var isBytes = item.p.Value is byte[];
                            //var bytes = typeof(byte[]);
                            //var eqBytes = item.p.Value.GetType() == bytes;


                            // double?
                            //Caused by: java.lang.RuntimeException: InternalCreateStatement, what to do with this? { CommandText = insert into `Book1.Middle` (`Title`, `Ratio`, `FooStateEnum`, `GooStateEnum`, `x`, `Tag`, `Timestamp`)  values (@Title, @Ratio, @FooStateEnum, @GooStateEnum, @x, @Tag, @Timestamp), type = java.lang.Double, item = { p = ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteParameter@1dc5180, i = 120 } }
                            //        at ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteCommand.InternalCreateStatement(__SQLiteCommand.java:225)
                            //        ... 89 more


                            var message = "InternalCreateStatement, what to do with this? " + new
                            {
                                this.CommandText,
                                type = item.p.Value.GetType(),

                                //isBytes,
                                //bytes,
                                //eqBytes,

                                item,
                            };

                            throw new InvalidOperationException(message);
                        }
                    }

                    // add values

                    this.InternalStatement = this.InternalPreparedStatement;
                }

                if (this.InternalStatement == null)
                {
                    this.InternalStatement = this.c.InternalConnection.createStatement();
                }
            }
            catch
            {
                throw;
            }

            //try
            //{
            //    // Caused by: java.lang.RuntimeException: GetFieldType fault: { ColumnType = 3, ordinal = 0, CommandText = select sum(`Deposit`)
            //    //        at ScriptCoreLib.Shared.Data.Diagnostics.QueryStrategyExtensions.Sum(QueryStrategyExtensions.java:124)
            //    //from `Book18.Sheet2`
            //    Console.WriteLine("\n__SQLiteCommand.InternalCreateStatement " + new
            //    {

            //        //CurrentThreadID = Thread.CurrentThread.ManagedThreadId,
            //        //CurrentThreadHashCode = Thread.CurrentThread.GetHashCode(),
            //        sql,
            //        //isReadOnly = this.c.InternalConnection.isReadOnly(),

            //        //  If the timeout period expires before the operation completes, this method returns false. A value of 0 indicates a timeout is not applied to the database operation.
            //        //isValid = this.c.InternalConnection.isValid(0)

            //    });
            //}
            //catch
            //{

            //}
        }
コード例 #2
0
 public OracleStatement(java.sql.Statement statement)
     : base(statement)
 {
 }
コード例 #3
0
        private void InternalCreateStatement()
        {
            // Z:\jsc.svn\examples\javascript\LINQ\test\auto\TestSelect\TestXMySQLCLRInsert\Program.cs
            // X:\jsc.svn\examples\java\appengine\Test\TestThreadManager\TestThreadManager\ApplicationWebService.cs

            //throw null;

            // tested by?

            if (this.InternalStatement != null)
                return;

            var sql = this.InternalCommandText;

            //Console.WriteLine("enter InternalCreateStatement" + new { sql });
            try
            {
                // http://www.javaworld.com/javaworld/jw-04-2007/jw-04-jdbc.html
                if (this.Parameters.InternalParameters.Count > 0)
                {

                    //Console.WriteLine("we have InternalParameters for " + sql);

                    var parameters = this.Parameters.InternalParameters;

                    var index =
                       from p in parameters
                       from i in this.CommandText.GetIndecies(p.ParameterName)
                       orderby i
                       select new { p, i };


                    // did we break it?
                    foreach (var p in parameters.ToArray())
                    {
                        // java seems to like indexed parameters instead
                        sql = sql.Replace(p.ParameterName, "?");
                    }

                    this.InternalPreparedStatement = this.c.InternalConnection.prepareStatement(sql);

                    var c = 0;
                    foreach (var item in index)
                    {
                        c++;

                        // X:\jsc.svn\examples\java\appengine\Test\TestThreadManager\TestThreadManager\ApplicationWebService.cs
                        // Z:\jsc.svn\examples\java\Test\TestIsinst\TestIsinst\Class1.cs

                        if (item.p.Value == null)
                        {
                            this.InternalPreparedStatement.setObject(c, null);
                        }
                        else if (item.p.Value is int)
                            this.InternalPreparedStatement.setInt(c, (int)item.p.Value);
                        else if (item.p.Value is long)
                            this.InternalPreparedStatement.setLong(c, (long)item.p.Value);
                        else if (item.p.Value is double)
                            // X:\jsc.svn\examples\javascript\forms\Test\TestSQLiteGroupBy\TestSQLiteGroupBy\ApplicationWebService.cs
                            this.InternalPreparedStatement.setDouble(c, (double)item.p.Value);
                        else if (item.p.Value is string)
                            this.InternalPreparedStatement.setString(c, (string)item.p.Value);
                        else if (item.p.Value is byte[])
                            this.InternalPreparedStatement.setBytes(c, (sbyte[])item.p.Value);
                        else
                        {
                            //Caused by: java.lang.RuntimeException: InternalCreateStatement, what to do with this? { CommandText = insert into Table1 (ContentValue, ContentBytes) values (@ContentValue /* text */, @ContentBytes), type = ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteParameter, isBytes = true, bytes = [B, eqBytes = true, item = { p = ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteParameter@1908330, i = 82 } }

                            // http://docs.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#setBytes(int, byte[])

                            //Caused by: java.lang.RuntimeException: InternalCreateStatement, what to do with this? 
                            // { CommandText = insert into Table1 (ContentValue, ContentBytes) values (@ContentValue /* text */, @ContentBytes), 
                            // item = { p = ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteParameter@47f703, i = 82 }, 
                            // type = __AnonymousTypes__ScriptCoreLibJava.__f__AnonymousType1_2 }

                            //var isBytes = item.p.Value is byte[];
                            //var bytes = typeof(byte[]);
                            //var eqBytes = item.p.Value.GetType() == bytes;


                            // double?
                            //Caused by: java.lang.RuntimeException: InternalCreateStatement, what to do with this? { CommandText = insert into `Book1.Middle` (`Title`, `Ratio`, `FooStateEnum`, `GooStateEnum`, `x`, `Tag`, `Timestamp`)  values (@Title, @Ratio, @FooStateEnum, @GooStateEnum, @x, @Tag, @Timestamp), type = java.lang.Double, item = { p = ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteParameter@1dc5180, i = 120 } }
                            //        at ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteCommand.InternalCreateStatement(__SQLiteCommand.java:225)
                            //        ... 89 more


                            var message = "InternalCreateStatement, what to do with this? " + new
                            {
                                this.CommandText,
                                type = item.p.Value.GetType(),

                                //isBytes,
                                //bytes,
                                //eqBytes,

                                item,
                            };

                            throw new InvalidOperationException(message);
                        }
                    }

                    // add values

                    this.InternalStatement = this.InternalPreparedStatement;
                }

                if (this.InternalStatement == null)
                    this.InternalStatement = this.c.InternalConnection.createStatement();
            }
            catch
            {
                throw;
            }

            //try
            //{
            //    // Caused by: java.lang.RuntimeException: GetFieldType fault: { ColumnType = 3, ordinal = 0, CommandText = select sum(`Deposit`)
            //    //        at ScriptCoreLib.Shared.Data.Diagnostics.QueryStrategyExtensions.Sum(QueryStrategyExtensions.java:124)
            //    //from `Book18.Sheet2`
            //    Console.WriteLine("\n__SQLiteCommand.InternalCreateStatement " + new
            //    {

            //        //CurrentThreadID = Thread.CurrentThread.ManagedThreadId,
            //        //CurrentThreadHashCode = Thread.CurrentThread.GetHashCode(),
            //        sql,
            //        //isReadOnly = this.c.InternalConnection.isReadOnly(),

            //        //  If the timeout period expires before the operation completes, this method returns false. A value of 0 indicates a timeout is not applied to the database operation.
            //        //isValid = this.c.InternalConnection.isValid(0)

            //    });
            //}
            //catch
            //{

            //}

        }
コード例 #4
0
		public Statement(java.sql.Statement statement) {
			_statement = statement;
		}