2

I've been using SQLite in my Java and C# applications, making use of the System.Data.SQLite library for C# and the Zentus SQLiteJDBC Driver for Java.

I've noticed that the Java implementation allows the use of the readily available SQL libraries that are included with the default Java installation whereas the C# implementation has to use specific SQLite versions of the C# equivalent.

Example:

C#

SQLiteConnection connection = null;
SQLiteCommand command = null;
SQLiteDataReader dReader = null;

float[] _data;

try
{
    connection = new SQLiteConnection(_connectionString);
    connection.Open();

Java

Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
float _data[];

try
{
    connection = DriverManager.getConnection(_connectionString);
    Statement st = connection.createStatement();

Is this down to how SQL databases are utilised in the languages or is it due to the implementations of the libraries, I'm interested to know more about the details leading to their usage.

0

3 Answers 3

3

I believe that Connection, PreparedStatement, and ResultSet are all interfaces, I believe. You could do the same thing in C# with IDbConnection, IDbCommand and IDataReader instead of the concrete SQLite implementations.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the information, is there any benefit between the two language implementations or are they practically the same in terms of performance etc.?
0

Java implementation allows the use of the readily available SQL libraries that are included with the default Java installation, but the connection string does differ , and you do need to import different driver(jar) for different types of databases.

So if I may say , Java as provided a wrapper as long as JDBC drivers are written for a database you want to use with java.

Comments

0

You can write the following in C#:

IDbConnection connection = null;
IDbCommand command = null;
IDataReader dReader = null;

float[] _data;

try
{
    connection = new SQLiteConnection(_connectionString);
    connection.Open();

The only thing that differs is that in Java there is a helper class DriverManager.

NOTE: The DataSource interface, new in the JDBC 2.0 API, provides another way to connect to a data source. The use of a DataSource object is the preferred means of connecting to a data source.

If you use DataSource, which is the preferred way of obtaining a connection, according to the DriverManager documentation, you'll also need to call the specific constructor of the SQLite implementation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.