bonjour j'ai une erreur au niveau de mon while (rs.next()) , je ne vois pas trop d'ou vien le probleme, j'ai peux être oublier quelque choses car ces la premièrr fois que j'utilise jodbc
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 import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Mysql { public static void main (String []args) throws SQLException { Connection conn = null; Statement stmt = null; ResultSet rs = null; try { conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/video?" +"user=root&password="); stmt = conn.createStatement(); // Do something with the Connection } catch (SQLException ex) { // handle any errors System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); } try { String req = "SELECT ID-DVD FROM dvd;"; System.out.println(req); rs = stmt.executeQuery("SELECT ID-DVD FROM dvd;"); } catch (SQLException e) { System.out.println("pb SQL"); } finally { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } while (rs.next()) { int num = rs.getInt("codeServ"); System.out.println(num); } rs.close(); stmt.close(); } }
Exception in thread "main" java.lang.NullPointerException
at Mysql.main(Mysql.java:55)
merci d'avance
Partager