vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Configuring Oracle for JDBC I am trying to set up a Linux (I am using Fedora Core 4) server with Oracle 10g on it but can't seem to be able to connect to it using JDBC. I don't know how to get my machine to respond to a specific name, but can ssh into it from within my own network by using: ssh jmecc@192.168.0.110 so I am trying the same with my JDBC connection string: "jdbc I modified the listener.ora file to LISTENER = (DESCRIPTION_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=jbox.jdomain)(PORT=15 21)) (ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1) ) ) SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (SID_NAME=test) (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1) (PROGRAM=extproc) ) ) and started this service using lsnrctl. I still get a "The Network Adapter could not establish the connection" error though. The problem may be in the DB setup though, as I can't login even using sqlplus from accounts that are not part of the 'oinstall' & 'dbus' groups. The 'oinstall' group gives too many permissions, so I shouldn't give this out to other users and anyway I don't know if a JDBC connection even assumes any particular user profile. Any input would be appreciated. Thanks, Jo |
| |||
| jmecc@telus.net wrote in news:1156699691.653564.301000@m79g2000cwm.googlegr oups.com: > Configuring Oracle for JDBC > > I am trying to set up a Linux (I am using Fedora Core 4) server with > Oracle 10g on it but can't seem to be able to connect to it using > JDBC. I don't know how to get my machine to respond to a specific > name, but can ssh into it from within my own network by using: > > ssh jmecc@192.168.0.110 > > so I am trying the same with my JDBC connection string: > > "jdbc > > I modified the listener.ora file to > > LISTENER = > (DESCRIPTION_LIST= > (ADDRESS=(PROTOCOL=tcp)(HOST=jbox.jdomain)(PORT=15 21)) > (ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1) > ) > ) > SID_LIST_LISTENER= > (SID_LIST= > (SID_DESC= > (SID_NAME=test) > (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1) > (PROGRAM=extproc) > ) > ) > > > and started this service using lsnrctl. I still get a "The Network > Adapter could not establish the connection" error though. > > The problem may be in the DB setup though, as I can't login even using > sqlplus from accounts that are not part of the 'oinstall' & > 'dbus' groups. The 'oinstall' group gives too many permissions, so I > shouldn't give this out to other users and anyway I don't know if > a JDBC connection even assumes any particular user profile. > > Any input would be appreciated. > Thanks, > Jo > > (HOST=jbox.jdomain) looks suspect to me. what happens if to the right of the "=" you use the same IP#? |
| |||
| That address didn't work either. I also tried localhost.localdomain there but to no avail. Am I on the right track though - I start an instance of the database from sqlplus / as sysdba, start a listener for port 1521, and then from another PC (on my network), start a Java connection using this port and local ip address? Thanks for replying. Jo |
| |||
| On 27 Aug 2006 10:28:11 -0700, jmecc@telus.net wrote: >Configuring Oracle for JDBC > >I am trying to set up a Linux (I am using Fedora Core 4) server with >Oracle 10g on it but can't seem to be able to connect to it using >JDBC. I don't know how to get my machine to respond to a specific >name, but can ssh into it from within my own network by using: > >ssh jmecc@192.168.0.110 > >so I am trying the same with my JDBC connection string: > >"jdbc > >I modified the listener.ora file to > >LISTENER = > (DESCRIPTION_LIST= > (ADDRESS=(PROTOCOL=tcp)(HOST=jbox.jdomain)(PORT=15 21)) > (ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1) > ) >) >SID_LIST_LISTENER= > (SID_LIST= > (SID_DESC= > (SID_NAME=test) > (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1) > (PROGRAM=extproc) > ) > ) > > >and started this service using lsnrctl. I still get a "The Network >Adapter could not establish the connection" error though. > >The problem may be in the DB setup though, as I can't login even using >sqlplus from accounts that are not part of the 'oinstall' & >'dbus' groups. The 'oinstall' group gives too many permissions, so I >shouldn't give this out to other users and anyway I don't know if >a JDBC connection even assumes any particular user profile. > >Any input would be appreciated. >Thanks, >Jo You shouldn't use a hardcoded ip in tnsnames.ora and a DNS name in listener.ora That you can't connect is a result from the server sending a different address back than the address you hardcoded in tnsnames.ora. Do NOT use hardcoded IPs, EVER! -- Sybrand Bakker, Senior Oracle DBA |
| |||
| You're right, but changing the 'HOST' in tnsnames.ora and listener.ora still doesn't allow the connection to be made despite the listener service starting without error in all cases. Although I have used (a bit) Linux and Oracle, I am new to setting both of them up so I may just be overlooking some parameter change or something. >From fresh error-free Linux & Oracle installations, what are the steps I need to take to make this machine accept JDBC connections? I am hoping someone knows a good tutorial; I have looked at many but they all explain how to install Linux/Oracle or how to use JDBC while none I have seen explain the part in the middle about getting this connection to work. Thanks, Jo |
| |||
| jmecc@telus.net wrote in news:1156723012.851595.125800@h48g2000cwc.googlegr oups.com: > You're right, but changing the 'HOST' in tnsnames.ora and listener.ora > still doesn't allow the connection to be made despite the listener > service starting without error in all cases. Although I have used (a > bit) Linux and Oracle, I am new to setting both of them up so I may > just be overlooking some parameter change or something. > >>From fresh error-free Linux & Oracle installations, what are the steps > I need to take to make this machine accept JDBC connections? I am > hoping someone knows a good tutorial; I have looked at many but they > all explain how to install Linux/Oracle or how to use JDBC while none I > have seen explain the part in the middle about getting this connection > to work. > > Thanks, > Jo > > Here is a free clue, Oracle does not know or care about the flavor of the client connecting to the DB. If any client can remotely connect to the database & a JDBC client can not connect, then the problem is with the JDBC client or network in between. FWIW - http://asktom.oracle.com has many fine coding examples. |
| |||
| jmecc@telus.net wrote: > You're right, but changing the 'HOST' in tnsnames.ora and listener.ora > still doesn't allow the connection to be made despite the listener > service starting without error in all cases. Although I have used (a > bit) Linux and Oracle, I am new to setting both of them up so I may > just be overlooking some parameter change or something. > > >From fresh error-free Linux & Oracle installations, what are the steps > I need to take to make this machine accept JDBC connections? I am > hoping someone knows a good tutorial; I have looked at many but they > all explain how to install Linux/Oracle or how to use JDBC while none I > have seen explain the part in the middle about getting this connection > to work. > > Thanks, > Jo Hi. I highly recommend using Oracle's JDBC driver in the thin mode, not the OCI/tnsnames.ora method. All you need is the machine name where the DBMS is running (or localhost if on the same box), the listener port (1521), and the SID (assuming a valid username and password: import java.util.*; import java.io.*; import java.sql.*; public class thin_connect_demo { public static void main(String argv[]) throws Exception { Connection c = null; try { Driver dr = (Driver)Class.forName("oracle.jdbc.OracleDriver"). newInstance(); Properties props = new Properties(); props.put("user", "scott"); props.put("password", "tiger"); c = dr.connect("jdbc System.out.println("The driver is " + c.getMetaData().getDriverVersion() ); System.out.println("The DBMS is " + c.getMetaData().getDatabaseProductVersion() ); } catch (Exception e) { e.printStackTrace(); } finally { try {c.close();} catch (Exception ignore){} } } } Joe Weinstein at BEA Systems |
| ||||
| It seems to work now!! I will run more tests to make sure that wasn't a fluke. After many modified files, Fedora would no longer boot, so I decided to start fresh from a new install and didn't install oracle until I got my networking going. This must have been the problem since this time once oracle was installed, I could connect to it. After a reboot I can connect after: 1) /etc/init.d/network restart (to start the networking, although there is likely some way to add this line to the system startup) 2) Starting the db instance (in sqlplus / as sysdba) 3) Starting the listener (lsnrctl start) Thank you IANAL_VISTA, Sybrand & joeNOSPAM Jo |