lundi 4 avril 2016

I cannot connect to sqlite db on Rapberry PI2 with Java

I'm using sqlite for my project and I'm developing with NetBeans IDE. I writed the code first on windows machine and haven't any problem. But when I moved the source code on raspberry I have problem. I cannot connect to sqlite db. Here is my code

public static void Init(String dbFileName) throws Exception
{
    if(dbFileName!=null)
    {
        if(!dbFileName.equals(""))
        {
            try
            {
                DB_FILE=dbFileName;
                Connection c = null;
                Class.forName("org.sqlite.JDBC");   
                c = DriverManager.getConnection("jdbc:sqlite:"+DB_FILE);
                connection = c;                                        
            }
            catch(Exception e)
            {
                throw new Exception( e.getClass().getName() + ": " + e.getMessage() );                    
            }
        } 
        else 
        {
            throw new Exception("...");
        }
    }
    else
    {
        throw new Exception("...");
    }

When I'm running I'm getting "java.sql.SQLException: Error opening connection" error... On terminal I can use sqlite3 command and select or update the db. Maybe it is a sqlite-jdbc problem. Can anyone explain me which steps I can do ?

Aucun commentaire:

Enregistrer un commentaire