Problem with database MySQL
13 Jul 2011 08:05:53 GMT
13 Jul 2011 08:40:23 GMT
13 Jul 2011 08:40:23 GMT
I found the solution:
just copy mysql-connector-java-. jar file into folder WEB-INF/lib
I found the solution:
just copy mysql-connector-java-. jar file into folder WEB-INF/lib
Hello everyone
I just use zkoss. In this days I created an application, which makes access to the database to fill a grid
but when I run application, the connection at the database not established, I have this output: com.mysql.jdbc.Driver
I set a new database for eclipse following this guide: http://books.zkoss.org/wiki/Setup_MySQL_DB_in_Eclipse
but output does not change.
Part of the code this is:
------file.zul
<zscript><![CDATA[
import vm.cloud.data.*;
List datas = ContributData.getContributors();
]]></zscript>
......
<zk forEach="${datas}">
......
------file.java
package vm.cloud.data;
import java.util.ArrayList;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;
public class ContributData{
private static String Nome="";
private static String Cognome="";
private static List<String[]> price= new ArrayList<String[]>();
private static String[] grid= new String[2];
private static void Select(){
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/agenda", "root", "");
Statement stm = conn.createStatement();
String query= "SELECT * FROM amici;";
ResultSet rst = stm.executeQuery(query);
if (rst.next()){Nome=rst.getString("Nome");
Cognome=rst.getString("Cognome");
}
grid[0]=Nome;
grid[1]=Cognome;
}catch(Exception e){System.out.print(e.getMessage());}
}
public static List<String[]> getContributors(){
Select();
Fillist();
return price;
}
private static void Fillist(){
for(int i=0;i<9;i++){
price.add(grid);}
}
}
Thank you very much