1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| package services;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
/**
*
* @author simo
*/
@WebService(serviceName = "afficherCategories")
public class afficherCategories {
Connection con= null;
PreparedStatement selectc=null;
ResultSet res=null;
String URL="jdbc:mysql://localhost:3306/projet_test";
String USERNAME="root";
String PASSWORD="";
public afficherCategories (){
try {
con=DriverManager.getConnection(URL,USERNAME, PASSWORD) ;
selectc=con.prepareStatement("select * from categorie");
while (res.next()){
System.out.println(res.getString(1) + " " + res.getString(2) );}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
/**
* Web service operation
*/
@WebMethod(operationName = "afficher")
public Void afficher() {
//TODO write your implementation code here:
return null;
}
} |
Partager