与Android和Jaybird驱动程序

时间:2016-05-24 12:00:58

标签: java android android-studio jdbc

我在创建与Firebird数据库的Android连接时遇到问题,当我执行应用程序没有崩溃时,但它没有返回任何结果,我知道问题是执行时连接线。

这是我的代码:



btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                try{
                    Class.forName("org.firebirdsql.jdbc.FBDriver").newInstance();
                    System.err.println("jdbc created");
                }catch(Exception e)
                {
                    System.err.println("Cannot create connection");
                    Toast.makeText(cntx, "erreur inisialisation", Toast.LENGTH_LONG).show();
                }
  
                try {
                  
                    Properties props = new Properties();
                    props.setProperty("user", "SYSDBA");
                    props.setProperty("password", "masterkey");
                    props.setProperty("encoding", "WIN1252");
                  
                    try {

                        System.err.println("creating connection");
                        java.sql.Connection connection =                DriverManager.getConnection("jdbc:firebirdsql:192.168.1.4:C:\\TEST.FDB", props);
                        System.err.println("created connection");
                      
                    } catch (Exception e) {
                        System.err.println("error in connection to server");
                        System.err.println(e.getMessage());
                        Log.v("TRACKKK", "Result : " + e.getMessage() + "  //  Localized message : " + e.getLocalizedMessage() + "  //  trace : " + e.getStackTrace());
                        Toast.makeText(cntx, "problem connexion", Toast.LENGTH_LONG).show();
                    }
                  

                } catch (Exception e) {
                    System.err.println("error in connection to server");
                    System.err.println(e.getMessage());
                    Toast.makeText(cntx, "Server Not Connected, Mybe your adress ip is wrrong", Toast.LENGTH_LONG).show();
                }
  
            }

 });




这是Android Studio的logcat中的消息:



05-24 12:20:18.268 27712-27712/com.formation.uk2015.testfirebird W/System.err: jdbc created
05-24 12:20:18.268 27712-27712/com.formation.uk2015.testfirebird W/System.err: creating connection
05-24 12:20:18.568 27712-27722/com.formation.uk2015.testfirebird W/art: Suspending all threads took: 7.689ms
05-24 12:20:18.568 27712-27712/com.formation.uk2015.testfirebird D/libc: [NET] android_getaddrinfofornet+,hn 11(0x3139322e313638),sn(),hints(known),family 0,flags 4
05-24 12:20:18.568 27712-27712/com.formation.uk2015.testfirebird D/libc: [NET] android_getaddrinfofornet-, SUCCESS
05-24 12:20:18.568 27712-27712/com.formation.uk2015.testfirebird W/System.err: error in connection to server
05-24 12:20:18.568 27712-27712/com.formation.uk2015.testfirebird W/System.err: null
05-24 12:20:18.568 27712-27712/com.formation.uk2015.testfirebird V/TRACKKK: Result : null  //  Localized message : null  //  trace : [Ljava.lang.StackTraceElement;@2d9311c0




我使用http://sourceforge.net/projects/androidjaybird/作为驱动程序 我已将libs和assets文件夹包含在我的项目中:

APP->

-assets

  • libs->
    • Jaybird2_2_4.jar。

Here is the strucrure of Asset and Jaybird driver added to my project

但是当我在eclipse中创建这个项目时,我没有遇到任何问题

0 个答案:

没有答案