Bonjour
Je veux établir une connexion a ma base oracle[10g pour vista], pour cela j'ai fait cette classe, mais toujours il ne fait pas la connexion, j’ai essayé toutes les URL possible, sachant que j’utilise
"http://pc-de-boughrara:5560/isqlplus" pour entrer dans "isqlplus" et elle marche bien, mais apparemment elle ne fonctionne pas pour la connexion. Qu’est ce qu’il faut faire ?
Voici ma classe:
aprés l'execution, la console eclipse[3.4] m'affiche ca :
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 import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import oracle.jdbc.*; // Pour les pilotes Oracle import oracle.sql.*; // Pour les spécificités SQL d'Oracle import oracle.jdbc.driver.*; public class orcl { Connection con = null; public void connexionBD() { try { Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.println ("driver etablie"); } catch (ClassNotFoundException e) { System.out.println ("driver not found"); e.printStackTrace(); } String URL = "jdbc:oracle:thin@:pc-de-boughrara:5560:orcl"; String USER = "scott"; String PASSWD = "jfive"; try { con =DriverManager.getConnection(URL,USER, PASSWD); System.out.println ("connexion base orcl etablie"); } catch (SQLException e) { System.out.println ("pas de connexion"); e.printStackTrace(); } } public static void main(String[] args) { orcl o = new orcl(); o.connexionBD(); } }
j'utilise le jar "ojdbc14".
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 driver etablie pas de connexion java.sql.SQLException: L'URL Oracle indiquée n'est pas valide at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:538) at java.sql.DriverManager.getConnection(DriverManager.java:525) at java.sql.DriverManager.getConnection(DriverManager.java:171) at orcl.connexionBD(orcl.java:27) at orcl.main(orcl.java:39)
merci pour toute information.
Partager