Reputation: 71
I'm trying to connect SQLite. Connect method:
public void connect() throws SQLException, ClassNotFoundException
{
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:C:\\..MY_PATH..\\data\\db.sqlite");
stmt = conn.createStatement();
}
public ResultSet query(String sql) throws SQLException
{
return stmt.executeQuery(sql);
}
And after this:
ResultSet rs = db.query(sql);
It give me an error - I'm trying to run the application, and it not working (tell that there some error in app, but not write the error). For every SQL command. I'm using intelliJ, the editor not give errors. Maybe the error with connection, but I not understand the problem.
Upvotes: 0
Views: 154
Reputation: 195
Instead of giving path in connection try to use
localhost / localhost IP
For example :
(jdbc:mysql:// { localhost/ localhost IP} / Database_Name)
And for error :
import android.util.Log;
Use:
Log.e(Tag,"Error : "+ variable_name(You want to console));
Upvotes: 0
Reputation: 16651
Android does not know what this "C:\" is. You have to use the local filesystem of the android device. I suggest you read up on this topic here: http://developer.android.com/guide/topics/data/data-storage.html
Upvotes: 2