0

I am looking to get started with SQL development and as such have decided to implement an application in both Java and C# that makes use of an SQL based database, in particular it will be a desktop application that stores certain types of data on the user machine through the database.

After reading the answer posted here: C# local database I have decided to use SQL Server 2008 - Compact for the C# version and now I am looking for a suitable alternative for the Java version.

Following on from another post in Stack Overflow a user has recommended Apache Derby and H2.

Would they be a suitable option for the Java application? The SQL 2008 Compact boasts how it's well suited for desktop application development, I don't want to have to install a bundle of software just to persuade Java to use "localhost".

I hope i've provided enough information, feel free to ask for anything inparticular.

Thanks!

Community
  • 1
  • 1
Jamie Keeling
  • 9,806
  • 17
  • 65
  • 102

3 Answers3

2

Have you considered sqlite? You could easily use it for both Java and C#. It's nice and compact and pretty easy to work with. Here's a discussion of using it with Java.

Community
  • 1
  • 1
chmullig
  • 13,006
  • 5
  • 35
  • 52
  • Sorry, I have to disagree. While sqlite might be a perfect choice for creating desktop applications, it's a bad one for getting started with SQL development. For that task, a "real" SQL database would be a better choice. – Axel Feb 14 '11 at 00:02
  • "in particular it will be a desktop application that stores certain types of data on the user machine through the database." A "real" SQL Database is not suited to that environment. You'll be adding significant overhead that's inappropriate for the problem you're actually trying to solve. – chmullig Feb 14 '11 at 05:04
  • I want to use the database so I can have the relationship between each piece of data. I did think about using XML but i'm not sure it would be suited to my needs, – Jamie Keeling Feb 14 '11 at 09:01
  • XML? Nobody is talking about XML. SQLite is a full SQL database in a local file. You can do queries, have multiple tables, run most of your normal SQLesque commands just fine. – chmullig Feb 14 '11 at 14:10
  • I don't understand, I assumed your comment was related to the structure of my data. You say I'm adding significant overhead but how would that be possible if I used SQlite? Surely it's designed for the desktop environment in mind... – Jamie Keeling Feb 14 '11 at 22:43
  • @Axel was saying that sqlite was inferior to "real" SQL alternatives like PostgreSQL, MySQL, Microsoft SQL or Oracle. I was disagreeing and saying that those heavier databases were inappropriate for a desktop application because they balloon your requirements. – chmullig Feb 14 '11 at 23:22
  • 1
    No, I didn't mean to say it's inferior per se. The important part in the original posting is this: "I am looking to get started with SQL development". – Axel Feb 15 '11 at 05:02
0

Why not use SQL Server 2008 also for the Java application? I recommend jTDS JDBC Driver.

Uhlen
  • 1,778
  • 15
  • 29
0

Yes, go with derby. All you have to do is include the jar file into your project and start a database connection like this:

// load database driver
String user = ...;
String password = ...;
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
Class.forName(driverName, false, this.getClass().getClassLoader());

// connect to database (replace DBName with your database name)
String url = "jdbc:derby:DBName;create=true;collation=TERRITORY_BASED"

Properties props = new Properties();
props.put("user", user);
props.put("password", password);

Connection connection = DriverManager.getConnection(url, props);

Then use the connection.

Axel
  • 13,939
  • 5
  • 50
  • 79