Menu

connection between android and firebird

hanane
2013-05-18
2016-04-28
  • hanane

    hanane - 2013-05-18

    Hello

    i m working on a project with firebird and android.My code is correct but when i try to run it gives me in logcat a lot of error of runTime:
    05-17 09:43:57.394: E/AndroidRuntime(302): FATAL EXCEPTION: main
    05-17 09:43:57.394: E/AndroidRuntime(302): java.lang.NoClassDefFoundError: org.firebirdsql.jdbc.FBDataSource
    05-17 09:43:57.394: E/AndroidRuntime(302): at org.firebirdsql.jdbc.AbstractDriver.createDataSource(AbstractDriver.java:138)
    05-17 09:43:57.394: E/AndroidRuntime(302): at org.firebirdsql.jdbc.AbstractDriver.connect(AbstractDriver.java:124)
    05-17 09:43:57.394: E/AndroidRuntime(302): at java.sql.DriverManager.getConnection(DriverManager.java:191)
    05-17 09:43:57.394: E/AndroidRuntime(302): at java.sql.DriverManager.getConnection(DriverManager.java:226)
    05-17 09:43:57.394: E/AndroidRuntime(302): at com.example.as.MainActivity.onCreate(MainActivity.java:25)
    05-17 09:43:57.394: E/AndroidRuntime(302): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    05-17 09:43:57.394: E/AndroidRuntime(302): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    05-17 09:43:57.394: E/AndroidRuntime(302): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    05-17 09:43:57.394: E/AndroidRuntime(302): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    05-17 09:43:57.394: E/AndroidRuntime(302): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    05-17 09:43:57.394: E/AndroidRuntime(302): at android.os.Handler.dispatchMessage(Handler.java:99)
    05-17 09:43:57.394: E/AndroidRuntime(302): at android.os.Looper.loop(Looper.java:123)
    05-17 09:43:57.394: E/AndroidRuntime(302): at android.app.ActivityThread.main(ActivityThread.java:4627)
    05-17 09:43:57.394: E/AndroidRuntime(302): at java.lang.reflect.Method.invokeNative(Native Method)
    05-17 09:43:57.394: E/AndroidRuntime(302): at java.lang.reflect.Method.invoke(Method.java:521)
    05-17 09:43:57.394: E/AndroidRuntime(302): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    05-17 09:43:57.394: E/AndroidRuntime(302): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    05-17 09:43:57.394: E/AndroidRuntime(302): at dalvik.system.NativeStart.main(Native Method)
    can you help me please?

     
  • Christian Mayer

    Christian Mayer - 2013-05-23

    Hello hanane,

    what IDE do you use ?
    Have you tried the example-project ?
    Does the example-project work for you ?
    In which folder in your project have you copied the files in the assets folder ?

    regards
    Christian

     
  • Christian Mayer

    Christian Mayer - 2013-05-23

    Hello hanane,

    just uploaded a new version of jaybird for android.
    I've tested the example-project (although just uploaded) it works.
    Which version of java do you use ?

    regards
    Christian

     
  • Reginaldo Antonietti

    Hello friends, I´m here again. I have the following code below in my test project. Could you help me where are my mistakes? I´m using JAYBIRD 2.2.4 and the JDK installed are 1.7. Thanks all for some help.

    package android_firebird.br.androidfirebird;

    import android.os.Bundle;
    import android.support.v7.app.ActionBarActivity;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Toast;
    import java.sql.*;

    public class MainActivity extends ActionBarActivity {

    private Button btn_conectar, btn_consultar;
    private EditText ed_cliente, ed_fone, ed_id;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        // Enable screen components
        btn_conectar = (Button) findViewById(R.id.btn_Conectar);
        btn_consultar = (Button) findViewById(R.id.btn_Consultar);
        ed_cliente = (EditText) findViewById(R.id.ed_Cliente);
        ed_fone = (EditText) findViewById(R.id.ed_Fone);
        ed_id = (EditText) findViewById(R.id.ed_ID);
    
        // Listeners
        btn_conectar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try{
                    Class.forName("org.firebirdsql.jdbc.FBDriver");
                    Toast.makeText(getApplicationContext(), "DRIVER JDBC FIREBIRD RECONHECIDO",Toast.LENGTH_LONG).show();
                    Connection connection = DriverManager.getConnection("jdbc:firebirdsql://SERVIDOR/3050:c:\\Dados\\SIS_PEDIDOS.FDB","SYSDBA","masterkey");
                }
                catch (ClassNotFoundException e) {
                    Toast.makeText(getApplicationContext(), "ERRO DE CLASSE DE DRIVER INEXISTENTE",Toast.LENGTH_LONG).show();
                    System.err.println(e.getMessage());
                } catch (SQLException e) {
                    Toast.makeText(getApplicationContext(), "ERRO DE EXCESSÃO DE SQL",Toast.LENGTH_LONG).show();
                    e.printStackTrace();
                }
            }
        });
    }
    
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
    
        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
    

    }

     
  • Christian Mayer

    Christian Mayer - 2015-01-04

    Use Java 1.6 please. The Android platform uses dalvik wich only support a very small set of Java 1.7 so i desided to distribute a java 1.6 compatible libraray only. If you have to use Java 1.7, compile the library by your self.

     
  • Michal

    Michal - 2016-04-28

    Do you mean change java version in gradle like this ? Or some else?

    compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_6
            targetCompatibility JavaVersion.VERSION_1_6
        }
    
     

    Last edit: Michal 2016-04-28

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.