je voudrais obtenir les informations sur un driver donné à partir de mon application.j'ai pris le code java suivant sur la faq java mais je n'arrive pas à l'utilisé.j'aurais besoin que quelqu'un m'aide à bien utilisé cette classe.
Voici le code java:
et voici le message à la compilation:
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 import java.sql.*; import java.io.*; public class infodriver { public static void main (String[] args) { Driver driver = new com.microsoft.sqlserver.jdbc.SQLServerDriver(); String url = "url JDBC"; int majorVersion = driver.getMajorVersion(); int minorVersion = driver.getMinorVersion(); DriverPropertyInfo[] props = driver.getPropertyInfo(url,null); System.out.println("Driver class = "+driver.getClass()+ " v"+majorVersion+"."+minorVersion); for(int i=0 ;i<props.length;i++){ DriverPropertyInfo prop = props[i]; System.out.println("Prop name = "+prop.name); System.out.println("Prop description = "+prop.description); System.out.println("Prop value = "+prop.value); if(prop.choices!=null){ for(int j=0;j<prop.choices.length;j++){ System.out.println("prop choice "+j+" = "+prop.choices[j]); } } } } }
PS: j'utilise Jcreator comme editeur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 --------------------Configuration: <Default>-------------------- C:\Documents and Settings\CRTV-SDA\Bureau\diaby\infodriver.java:9: unreported exception java.sql.SQLException; must be caught or declared to be thrown DriverPropertyInfo[] props = driver.getPropertyInfo(url,null); ^ 1 error Process completed.
Merci d'avance
Partager