<%@ page import="java.sql.*" %><% String driver=request.getParameter("driver"); if(driver==null) driver="sun.jdbc.odbc.JdbcOdbcDriver"; String dburl=request.getParameter("dburl"); if(dburl==null) dburl="jdbc:odbc:ECOM"; // quand la source ODBC s'appelle ECOM String dbusername=request.getParameter("dbusername"); if(dbusername==null) dbusername="admin"; String dbpassword=request.getParameter("dbpassword"); if(dbpassword==null) dbpassword="nimda"; String sqlstatement= "SELECT * FROM Query WHERE q=?"; String encoding=request.getParameter("encoding"); if(encoding==null) encoding="iso-8859-1"; // "UTF-8", ... String q=request.getParameter("q"); if(q==null) q="1"; int qn=Integer.parseInt(q); %> Tutoriel SQL : Question #<%=qn%> <% String question=null; String sqlquery=null; Class.forName(driver); Connection cnx = DriverManager.getConnection(dburl,dbusername,dbpassword) ; PreparedStatement stmt = cnx.prepareStatement(sqlstatement); stmt.setInt(1,qn); if (stmt.execute()) { ResultSet rs = stmt.getResultSet(); if(rs.next()) { question=rs.getString("question"); sqlquery=rs.getString("sqlquery"); } rs.close(); } if(question==null || sqlquery==null) { // query #1 qn=1; stmt.setInt(1,1); if (stmt.execute()) { ResultSet rs = stmt.getResultSet(); if(rs.next()) { question=rs.getString("question"); sqlquery=rs.getString("sqlquery"); } rs.close(); } } cnx.close(); %>
<% if(qn>1) { %> Précédente
<% } %> Suivante
Schéma de la base
Impression
Question #<%=qn%>: <%=question%>

Résultat Attendu
Réponse