开发者

Java alternative to SQL Server 2008 - Compact

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 a开发者_如何学Pythonpplication 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!


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜