2010-07-19 132 views
-2

我正在學習gwt,我遇到了麻煩,試圖做一個查詢 沒有源代碼可用於[package.Class]類型;你忘了繼承一個必需的模塊嗎?GWT JDBC我該怎麼辦?

我不很瞭解如何工作的模塊

做我必須寫爲每個類模塊?

我只是想調用一個類中插入數據

感謝提前

+0

如果你不瞭解像GWT這樣的基本術語(如GWT),你期望如何使用GWT?請前往官方文檔(http://code.google.com/webtoolkit/overview.html)並從頭開始 - 不要跳過,否則它會最終咬你。或者你最終會寫一些值得DailyWTF的代碼;) – 2010-07-19 22:20:01

回答

0

爲了連接你應該學會RPC數據庫你學習後,您可以創建可服務類implemtent像

public class ExampleServiceImpl extends RemoteServiceServlet implements ExampleService{ 

//private Connection con=null; 
    private String status; 
    private String url="jdbc:mysql://localhost:3306/test"; 
    private String user="test"; 
    private String pass = ""; 
    private Person people; 
    private ResultSet resultSet=null; 
    private Statement stm=null; 
    private Connection con=null; 

    private Statement stm2=null; 
    private Connection conn2=null; 
    private ResultSet resultSet2=null; 
    private MySqlConnection conn=new MySqlConnection(); 


@Override 
public Person getPerson(String name,String surname,int password) { 
    Person personinfo=new Person(); 
    personinfo.setName(name); 
    personinfo.setSurname(surname); 
    personinfo.setPassword(password); 

    ResultSet resultSet=null; 
    Statement stm=null; 
    Connection con=null; 

    MySqlConnection conn=new MySqlConnection();  
     con = conn.getConnection(); 

     stm = ((Connection) con).createStatement(); 

    String sorgu = "SELECT * FROM person"; 

     resultSet = stm.executeQuery(sorgu); 

    while(true){ 
    String sql = "INSERT INTO person " + 
       "VALUES ("+ password +", '" + name+ "','" + surname + "')"; 


     stm.executeUpdate(sql); 

     ((Connection) con).setAutoCommit(false); 

     ((Connection) con).commit(); 
    stm.close(); 


    return personinfo; 
    } 
} 

在此代碼的類,你可以插入一個Person對象數據庫