我正在开发一个应用程序eclipse
并使用对象相关映射(ORMLite)来访问我的mysql
服务器。数据层是编译的另一个项目java
并绑定为我的 android 应用程序的引用
我在 datalayer 项目中引用了与 ormlite 一起使用的每个 *.jar 文件。但是在运行我的应用程序时,我收到以下错误消息:
"Could not find class 'com.j256.ormlite.jdbc.JdbcConnectionSource',
referenced from method
com.pos.datalayer.querybuilder.DatabaseWorker.connectionSetup"
这是我的 DatabaseWorker 类的代码:
public class DatabaseWorker implements DatalayerWorkable {
private Type tableMapping = null;
private String actionOnDatabase = null;
private UserBO persistedUser = null;
private Type retVal = null;
public static String hostString = "jdbc:mysql://lucid.selfhost.me/pos";
private static JdbcConnectionSource connection = null;
public DatabaseWorker () { };
public Type loadData( String databaseAction, final Type tableMap ) {
actionOnDatabase = databaseAction;
tableMapping = tableMap;
Thread workerThread = new Thread(new Runnable(){
public void run() {
try {
connection = connectionSetup();
if(actionOnDatabase == "GetLogin"){
retVal = loadUserData(tableMap);
}else if (actionOnDatabase == "loadHotDealz"){
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(connection != null){
//closeConnection(connection);
connection = null;
}
}
}
});
workerThread.start();
return retVal;
}
public boolean persistData( String databaseAction, Type tableMap ) {
Thread workerThread = new Thread(new Runnable(){
public void run(){
}
});
return false;
}
private JdbcConnectionSource connectionSetup() throws SQLException{
//set up sql-connection
JdbcConnectionSource connection = new JdbcConnectionSource(hostString);
((JdbcConnectionSource) connection).setUsername("guest");
((JdbcConnectionSource) connection).setPassword("ObivanK3nobi");
return connection;
}
private void closeConnection(JdbcConnectionSource openedConnection){
try{
if(openedConnection != null){
openedConnection.close();
}
}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private Type loadUserData(Type tableMapping) throws SQLException{
Dao<UserBO, String> accountDao = null;
if(connection != null){
accountDao = DaoManager.createDao(connection, tableMapping.getClass());
String currentUser = ((UserBO) tableMapping).getUser();
//execute query
persistedUser = accountDao.queryForId(currentUser);
if(persistedUser != null){
persistedUser.setIsLoggedin(1);
accountDao.update(persistedUser);
}
}
return persistedUser;
}
public Type getDatabaseResult(){
return retVal;
}
public void databaseObjCallback(Type databaseResult) {
throw new UnsupportedOperationException("Not implemented yet");
}
}
我将不胜感激任何帮助解决我的问题!