je veux établir une connexion odbc.jdbc et j'ai essayé ce code:
mais malheuresement il affiche :
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 <HTML> <HEAD> <TITLE>JSP JDBC Example 1</TITLE> </HEAD> <BODY> <!-- Set the scripting language to java and --> <!-- import the java.sql package --> <%@ page language="java" import="java.sql.*" import="java.io.*" %> <%@ page session = "true" %> <%@ page buffer="none" %> <% Connection con = null; try { // Load the Driver class file Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // Make a connection to the ODBC datasource Movie Catalog con = DriverManager.getConnection("jdbc:odbc:mabd1","",""); // Create the statement Statement statement = con.createStatement(); // Use the created statement to SELECT the DATA // FROM the Titles Table. ResultSet rs = statement.executeQuery("SELECT * FROM livres"); // Iterate over the ResultSet %> <!-- Add an HTML table to format the results --> <TABLE BORDER="1"> <TR> <TH>code</TH><TH>titre</TH><TH>Prixvente</TH><TH>nblivre</TH> <% while ( rs.next() ) { // get the title_name, which is a String out.println("<TR>\n<TD>" + rs.getString("code")+ "</TD>"); // get the rating out.println("<TD>" + rs.getString("titre") + "</TD>"); // get the price out.println("<TD>" + rs.getString("Prixvente") + "</TD>"); // get the quantity out.println("<TD>" + rs.getString("nblivre")+ "</TD>\n</TR>"); } // Close the ResultSet rs.close(); } catch (IOException ioe) { out.println(ioe.getMessage()); } catch (SQLException sqle) { out.println(sqle.getMessage()); } catch (ClassNotFoundException cnfe) { out.println(cnfe.getMessage()); } catch (Exception e) { out.println(e.getMessage()); } finally { try { if ( con != null ) { // Close the connection no matter what con.close(); } } catch (SQLException sqle) { out.println(sqle.getMessage()); } } %> </BODY> </HTML>
[Microsoft][Gestionnaire de pilotes ODBC] Source de données introuvable et nom de pilote non spécifié
sachant que j'ai bien établie la connexion dans un programme .java.
pouvez-vous m'indiquer où est le problème?
j'attend vos réponses.
merci
Partager