Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using create=true; in JTDS

 
Franklin Wormwood
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand in Apache Derby, if you put

create=true;

in the connection URL, the driver will create the database if the database does not exist. Can we do the same in JTDS?

Connection connection = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/sample;create=true", "user", "password");

But I'm getting an sqlException saying the object sample cannot be found. How can I do this in JTDS?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I highly doubt that creating a DB is possible via connection parameters for any DBs aside from the likes of Derby and HSQLDB.
 
Franklin Wormwood
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:I highly doubt that creating a DB is possible via connection parameters for any DBs aside from the likes of Derby and HSQLDB.

That's too bad. I'm trying to run Marty Hall's example on creating a db using JDBC. He did it on Apache Derby, I was hoping to try it in sql server cause sql server is the dbms in my machine.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the problem with creating the DB manually?
 
Franklin Wormwood
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:What's the problem with creating the DB manually?

Not at all. Though you wouldn't normally create databases from java, It's just interesting if you can do that in java.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those two DBs can operate in non-persistent mode, holding the data completely in-memory. It makes sense to create the DB programmatically as well in that case.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic