2016-05-16 38 views
1

我在构建代码名为1的移动应用程序时遇到以下错误。将代码名称1连接到php/mysql

的代码是没有代号项目

public Actualite[] select(){ 
     try { 
      ActualiteHandler matchHandler = new ActualiteHandler(); 
      // get a parser object 
      SAXParser SAXparser = SAXParserFactory.newInstance().newSAXParser(); 
      // get an InputStream from somewhere (could be HttpConnection, for example) 
      HttpConnection hc = (HttpConnection) Connector.open("http://localhost/abbes/select.php");//people.xml est un exemple 
      DataInputStream dis = new DataInputStream(hc.openDataInputStream()); 
         dis.toString(); 
      SAXparser.parse(dis, matchHandler); 
      // display the result 
      matches = matchHandler.getMatch(); 
      return matches; 
     } catch (ParserConfigurationException ex) { 
      ex.printStackTrace(); 
     } catch (SAXException ex) { 
      ex.printStackTrace(); 
     } catch (IOException ex) { 
      ex.printStackTrace(); 
     } 

      return null; 
    } 

在这里工作是错误

error: cannot access File 
SAXparser.parse(dis, matchHandler); 
class file for java.io.File not found 

回答

0

无论SAXParser也不java.io.File由代号一个支持。

我也看到你使用Connector这是一个J2ME类,不受支持。您需要使用XMLParserFileSystemStorage

查看开发指南covering this functionality here。

+0

只是为了增加这个功能,这个新帖子涵盖了后端与mysql的连接:https://www.codenameone.com/blog/connecting-to-a-mysql-database.html –