I think you need to read the JDBC documentation.
Specifically, the tutorial around how to use PreparedStatement.

http://download.oracle.com/javase/tutorial/jdbc/basics/prepared.html

tuc70899 wrote:
> Hello,
>
> I am setting up a CLOB and wanted to measure its performance at large
> sizes. My application compiles but is throwing an error.
>
> So far I have...
> public class MyClob {
>
>
>     public static void main(String... args) throws Exception {
>         // delete the database named 'test' in the user home directory
>         DeleteDbFiles.execute("~", "test", true);
>
>         Class.forName("org.h2.Driver");
>         Connection conn = DriverManager.getConnection("jdbc:h2:~/
> test");
>         Statement stat = conn.createStatement();
>         String query = "select * from test";
>
>         stat.execute("create table test(id int primary key, name
> varchar(255))");
>         PreparedStatement prep = conn.prepareStatement( query );
>
>         prep.setString(1, "Hi");
>
>         stat.execute("insert into test values(1, 'Hello')");
>
>         ResultSet rs;
>         rs = prep.executeQuery("select * from test");
>         while (rs.next()) {
>               Clob cl = rs.getClob(1);
>             System.out.println("This has " + cl.length() + "
> characters.");
>             System.out.println(rs.getString("name"));
>         }
>         stat.close();
>         prep.close();
>         conn.close();
>     }
>
> }
> Which throws an error:
> Exception in thread "main" org.h2.jdbc.JdbcSQLException: Invalid value
> "1" for parameter "parameterIndex" [90008-153]
>       at org.h2.message.DbException.getJdbcSQLException(DbException.java:
> 327)
>       at org.h2.message.DbException.get(DbException.java:167)
>       at
> org.h2.message.DbException.getInvalidValueException(DbException.java:
> 213)
>       at
> org.h2.jdbc.JdbcPreparedStatement.setParameter(JdbcPreparedStatement.java:
> 1274)
>       at
> org.h2.jdbc.JdbcPreparedStatement.setString(JdbcPreparedStatement.java:
> 327)
>       at org.h2.samples.MyClob.main(MyClob.java:36)
>
>
> Thanks,
> Michael
>
> On Apr 1, 3:56 pm, Thomas Mueller <[email protected]>
> wrote:
>> Hi,
>>
>>> I don't see the directory "h2/h2/ext". Would it be made during the
>>> build, do you know?
>> Yes, 
>> see:http://h2database.com/html/installation.htmlhttp://h2database.com/html/build.html#building
>>
>>> Test very large databases and LOBs (up to 256 GB).
>>>  Would happen to have any scripts that I could use to initialize these 
>>> databases?
>> Sorry, what is the question exactly? Do you ask if I already have a
>> script? Or do you ask if I would like a script?
>>
>> I don't have one, but it would be relatively easy to create one.
>>
>> Regards,
>> Thomas

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to