This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Using create=true; in JTDS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Using create=true; in JTDS" Watch "Using create=true; in JTDS" New topic
Author

Using create=true; in JTDS

Franklin Wormwood
Greenhorn

Joined: Jun 16, 2014
Posts: 17
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

Joined: Mar 22, 2005
Posts: 42958
    
  73
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

Joined: Jun 16, 2014
Posts: 17
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

Joined: Mar 22, 2005
Posts: 42958
    
  73
What's the problem with creating the DB manually?
Franklin Wormwood
Greenhorn

Joined: Jun 16, 2014
Posts: 17
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

Joined: Mar 22, 2005
Posts: 42958
    
  73
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using create=true; in JTDS
 
It's not a secret anymore!