How can I resolve-oracle-11g-xe using eclipse

rule for tcp port 1521 I am trying to create a sample JDBC program i that I have to create, but I ran into this problem, I tried many solutions present on the Internet, all I need to know is that the service is missing, but have not found the exact solution. I am starting at JDBC, any help would be appreciated.

My JDBC program: -

import java.sql.*; public class JdbcExample { /** * @param args * @throws ClassNotFoundException * @throws SQLException */ public static void main(String[] args) throws ClassNotFoundException, SQLException { // TODO Auto-generated method stub String userName="system",password="admin",url="jdbc:oracle:thin:localhost:1521:xe"; Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection(url, userName, password); System.out.println(con); Statement stmt = con.createStatement(); System.out.println(stmt); int b = stmt.executeUpdate("create table emp(eno number(5),name varchar2(20));"); System.out.println("Table Created" + b); // if(b) // { // // } // else // System.out.print("WTF"); } 

My LogCat: -

 java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=186646784)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333) at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404) at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at JdbcExample.main(JdbcExample.java:19) 

My listener.ora

 SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = J:\app\oracle\product\11.2.0\server) (PROGRAM = extproc) ) (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = J:\app\oracle\product\11.2.0\server) (PROGRAM = extproc) ))LISTENER =(DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ))DEFAULT_SERVICE_LISTENER = (XE) 

Thanks in advance. NOTE. I included the ojdbc14_g.jar file in my buildconfig file.

0
java eclipse oracle jdbc
Jul 24 '17 at 15:39
source share
2 answers

Try changing:

 "jdbc:oracle:thin:localhost:1521:xe" 

at

 "jdbc:oracle:thin:@//localhost:1521/XE" 
0
Jul 24. '17 at 15:52
source share
— -

Try changing the JDBC connection string as follows:

 "jdbc:oracle:thin:localhost:1521:xe" 

to the next:

 "jdbc:oracle:thin:@localhost:1521:xe" 

You need to understand when to use : and / based on using the SID or SERVICE NAME

 INSTANCE SID by ":" jdbc:oracle:thin:@localhost:1521:SID SERVICE NAME by "/" jdbc:oracle:thin:@localhost:1521/SERVICE_NAME 

Hope this helps!

0
Jul 25 '17 at 6:07
source share



All Articles