Hi,

> Documentation has not been updated that you may specify schema name.

Thanks! You are right, it is not documented in the advanced section. I
will do that.

So far it is only documented in the grammar section so far:
http://www.h2database.com/html/grammar.html#createlinkedtable

Regards,
Thomas

> Pavel
>
> On Oct 10, 11:32 am, "Thomas Mueller" <[EMAIL PROTECTED]>
> wrote:
>> Hi,
>>
>> The problem is that two tables with the same name exist. There was a
>> change recently to support schema names in CREATE LINKED TABLE. Now it
>> behaves like DatabaseMetaData.getTables: when you don't specify a
>> schema name, all schemas are searched. An empty string means the table
>> without schema. Example:
>>
>> Class.forName(Driver.class.getName());
>> Connection ca = DriverManager.getConnection("jdbc:h2:mem:1");
>> Statement sa = ca.createStatement();
>> sa.execute("CREATE SCHEMA Y");
>> sa.execute("CREATE TABLE Y.A (X INT)");
>> sa.execute("CREATE TABLE A(Y INT)");
>> sa.execute("CREATE TABLE Y.B(Z INT)");
>> Connection cb = DriverManager.getConnection("jdbc:h2:mem:2");
>> Statement sb = cb.createStatement();
>> sb.execute("CREATE LINKED TABLE one('', 'jdbc:h2:mem:1', '', '', 'Y', 
>> 'A');");
>> sb.execute("CREATE LINKED TABLE two('', 'jdbc:h2:mem:1', '', '', '', 'A');");
>> sb.execute("CREATE LINKED TABLE three('', 'jdbc:h2:mem:1', '', '', 'B');");
>> sb.execute("SELECT X FROM one");
>> sb.execute("SELECT Y FROM two");
>> sb.execute("SELECT Z FROM three");
>> ca.close();
>> cb.close();
>>
>> Regards,
>> Thomas
>>
>> On Fri, Oct 10, 2008 at 4:01 PM, Pavel <[EMAIL PROTECTED]> wrote:
>>
>> > Hi Thomas,
>>
>> > Database version 10-04-2008.
>>
>> > The test below fails with the error. Is it expected behavior or it is
>> > bug in the program?
>>
>> > Exception in thread "main" org.h2.jdbc.JdbcSQLException: Schema name
>> > must match [90080-100]
>> >        at org.h2.message.Message.getSQLException(Message.java:103)
>> >        at org.h2.message.Message.getSQLException(Message.java:114)
>> >        at org.h2.message.Message.getSQLException(Message.java:77)
>> >        at org.h2.table.TableLink.readMetaData(TableLink.java:98)
>> >        at org.h2.table.TableLink.connect(TableLink.java:82)
>> >        at org.h2.table.TableLink.<init>(TableLink.java:65)
>> >        at org.h2.schema.Schema.createTableLink(Schema.java:470)
>> >        at 
>> > org.h2.command.ddl.CreateLinkedTable.update(CreateLinkedTable.java:
>> > 78)
>> >        at org.h2.command.CommandContainer.update(CommandContainer.java:69)
>> >        at org.h2.command.Command.executeUpdate(Command.java:206)
>> >        at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:163)
>> >        at org.h2.samples.Test.main(Test.java:28)
>> >        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> >        at
>> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
>> > 39)
>> >        at
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
>> > 25)
>> >        at java.lang.reflect.Method.invoke(Method.java:585)
>> >        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:
>> > 90)
>>
>> >    public static void main(String[] args) throws SQLException,
>> > ClassNotFoundException {
>>
>> >        Class.forName(Driver.class.getName());
>> >        Connection ca = DriverManager.getConnection("jdbc:h2:mem:one",
>> > "linkuser", "linkpass");
>>
>> >        Statement sa = ca.createStatement();
>> >        sa.execute("CREATE SCHEMA Y");
>>
>> >        sa.execute("CREATE TABLE A( C INT)");
>> >        sa.execute("CREATE TABLE Y.A (C INT)");
>>
>> >        Connection cb =
>> > DriverManager.getConnection("jdbc:h2:mem:two");
>>
>> >        Statement sb = cb.createStatement();
>>
>> >        sb.execute("CREATE LINKED TABLE one('org.h2.Driver',
>> > 'jdbc:h2:mem:one', 'linkuser', 'linkpass', 'Y.A');"); //OK
>> >        sb.execute("CREATE LINKED TABLE two('org.h2.Driver',
>> > 'jdbc:h2:mem:one', 'linkuser', 'linkpass', 'A');"); //FAILS
>> >        ca.close();
>> >        cb.close();
>> >    }
> >
>

--~--~---------~--~----~------------~-------~--~----~
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