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 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class consulter extends HttpServlet{
public void init(ServletConfig config) throws ServletException{
super.init(config);
}
/**Process the HTTP Get request*/
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException{
Connection connection=null;
res.setContentType("text/html");
PrintWriter out = res.getWriter();
try {
Class.forName("com.hxtt.sql.paradox.ParadoxDriver").newInstance();
String url = "jdbc:paradox:/e:";
connection = DriverManager.getConnection(url);
Statement commande = connection.createStatement();
ResultSet RS = commande.executeQuery("select code FROM test");
while(RS.next())
{
String nom=RS.getString("code");
}
RS.close();
commande.close();
}
catch(ClassNotFoundException e){
out.println("Couldn't load database driver: " + e.getMessage());
}
catch(SQLException e){
out.println("SQLException caught: " + e.getMessage());
}
catch (Exception e){
out.println(e);
}
finally {
try {
if (connection != null) connection.close();
}
catch (SQLException ignored){
out.println(ignored);
}
}
} |
Partager