bonsoir ,

comment faire pour utiliser un servlet depuis une page jsp
en faite je veux executer un requête sql depuis ma page jsp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
package Composants;
import java.util.*;
import java.sql.*;
import java.io.*;
 
public class ConnexionBD {
 ResultSet res;
  Connection dbCon;
  Statement stmt;
 
  public  ConnexionBD(String dsn, String username, String password)
  {
    try{
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    dbCon=DriverManager.getConnection("url,username,password);
    }catch(Exception e){}
  }
 
  public ResultSet executerSelect(String req) throws SQLException
  {
 
    try{
    stmt=dbCon.createStatement();
    res=stmt.executeQuery(req);}
  catch (SQLException sqle){System.out.println("Exception de bd");}
    return res;
  }
public void executerInsert(String req) throws SQLException{
stmt = dbCon.createStatement();
  res=stmt.executeQuery(req);
 
 
}
  public int executerUpdate(String req) throws SQLException
  {
    int x=0;
    stmt=dbCon.createStatement();
    x=stmt.executeUpdate(req);
 
    return x;
  }
 
}