title: Getting unknown database exception while creating schema programmatically?
body: <p>I am trying to create schema and tables programmatically using hibernate/GWT/Java. I created the configuration with all mapping resources and properties etc. follows,</p>
  
  <pre><code>Configuration hibConfiguration = new Configuration().configure(configFileDoc);
  </code></pre>
  
  <p>but when I say </p>
  
  <pre><code>SchemaExport schemaExport = new SchemaExport(hibConfiguration);
  schemaExport.create(true, true);
  </code></pre>
  
  <p>it is throwing exception as,</p>
  
  <pre><code>ERROR: HHH000231: Schema export unsuccessful
  
      com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'testschema'
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
          at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
          at com.mysql.jdbc.Util.getInstance(Util.java:386)
          at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
          at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
          at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
          at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943)
          at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4113)
          at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1308)
          at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2336)
          at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)
          at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)
          at com.mysql.jdbc.ConnectionImpl.&lt;init&gt;(ConnectionImpl.java:792)
          at com.mysql.jdbc.JDBC4Connection.&lt;init&gt;(JDBC4Connection.java:47)
          at sun.reflect.GeneratedConstructorAccessor36.newInstance(Unknown Source)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
          at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
          at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
          at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
          at java.sql.DriverManager.getConnection(DriverManager.java:582)
          at java.sql.DriverManager.getConnection(DriverManager.java:154)
          at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193)
          at org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:55)
          at org.hibernate.tool.hbm2ddl.DatabaseExporter.&lt;init&gt;(DatabaseExporter.java:52)
          at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:367)
          at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:304)
          at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:293)
  </code></pre>
  
  <p><strong>my cfg.xml file</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;hibernate-configuration&gt;
     &lt;session-factory&gt;
        &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
        &lt;property name="hibernate.connection.password"&gt;passwd&lt;/property&gt;
        &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
        &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3306/testSchema&lt;/property&gt;
        &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
        &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5InnoDBDialect&lt;/property&gt;
        &lt;property name="javax.persistence.validation.mode"&gt;none&lt;/property&gt;
        &lt;property name="hibernate.temp.use_jdbc_metadata_defaults"&gt;false&lt;/property&gt;
        &lt;property name="hibernate.default_entity_mode"&gt;dynamic-map&lt;/property&gt;
        &lt;property name="hibernate.hbm2ddl.auto"&gt;create&lt;/property&gt;
     &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>And If I manually created the schema then it is working fine, i.e. creating tables and columns also. But normally it is not creating schema, Is it not possible to create schema automatically?</p>