如何将MS ACCESS连接到Android应用程序

时间:2013-09-29 13:41:32

标签: java android eclipse jdbc odbc

感谢我的项目出现问题之前,我的项目是在Android中制作应用程序然后应用程序可以连接到我公司的数据库,但这不是连接

这是我的剧本

 package mas.ganteng;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Mas Ganteng Indonesia
 */
     public class ConnectedAccessActivity {
 Connection conn;
 String url="jdbc:odbc:JavaMsAccess";
 String user="";
 String pass="";
 public Connection getConnection(){
 try {
 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 conn=DriverManager.getConnection(url,user,pass);
 System.out.println("Connected!!!");
 } catch (SQLException ex) {
 Logger.getLogger(ConnectedAccessActivity.class.getName()).log(Level.SEVERE, null, ex);
 } catch (ClassNotFoundException ex) {
 Logger.getLogger(ConnectedAccessActivity.class.getName()).log(Level.SEVERE, null, ex);
 }
 return conn;
 }
 public static void main(String [] args){
 ConnectedAccessActivity acc=new ConnectedAccessActivity();
 acc.getConnection();
 }

}

它是eclipse中的控制台

    Invalid layout of java.lang.String at value
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (javaClasses.cpp:124), pid=3848, tid=3876
#  fatal error: Invalid layout of preloaded class
#
# JRE version:  (8.0-b104) (build )
# Java VM: Java HotSpot(TM) Client VM (25.0-b46 mixed mode windows-x86 )
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\My Android\ConnectedAccess\hs_err_pid3848.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#

你能帮帮我解决这个错误?????

1 个答案:

答案 0 :(得分:0)

  

java.lang.String的值布局无效

您尝试将Android应用作为常规Java程序运行。在Android模拟器或实际设备上运行Android应用。

代码看起来只是一个普通的Java程序。您应该从中删除Android库,以便能够以Java格式运行它。