• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invalid oracle URL

 
Ramesh kangamuthu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When I try to establish the connection to the oracle 9i database server
from my main method java client,I got "Invalid Oracle URL specified" exception.I have given the code below.I hope that the problem will be solved very soon.I use "classes12.jar" as JDBC Driver for my program.please help me to solve the problem.because I am in a hurry to complete the project,which has the remaining work as oracle JDBC connection.

//Example program for oracle database connection

import java.sql.*;
import oracle.jdbc.OracleDriver;

public class CRMOracleAccess
{
public static void main(String[] args) throws ClassNotFoundException
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con1=DriverManager.getConnection("jdbcracleci8@CRM2","scott","tiger");
System.out.println("Connection has been established");
Statement stmt=con1.createStatement();
stmt.executeUpdate("insert into Marketing values('team1123','Vimal')");
System.out.println("A record has been inserted");
ResultSet rs=stmt.executeQuery("select * from Marketing where customer_id="+"'team123'");
while(rs.next())
{
System.out.println("Customer ID is "+rs.getString("customer_id")+"Customer name is "+rs.getString("customer_name"));
}
}
catch(SQLException ex)
{
System.err.println("SQLException is"+ex.getMessage());
System.err.println("Error Code is "+ex.getSQLState());
//ex.printStackTrace();
}
}
}
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this work from your operazting system command prompt?

> tnsping CRM2
or
> tnsping80 CRM2

Also Oracle advises to register your driver first:


Regards, Jan
 
Ramesh kangamuthu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jan,
I have given the wrong database name as CRM2 and now I corrected it as "Srm".
the command "tnsping Srm" works and displays

attempting to contact <DESCRIPTION = <ADDRESS_LIST = <ADDRESS = <PROTOCOL = TCP><HOST =sys9><PORT =1521>>><CONNECT_DATA =<SERVER = DEDICATED><SERVICE_NAME = Srm>>>
ok <20 msec>

But from my java application there is no connection established and also no error.

also i changed my code into as follows
Connection con1=DriverManager.getConnection("jdbcracle:thin@sys9:1521:Srm","scott","tiger");

but still it is resultless.

thanks ans regards,
Ramesh kangamuthu
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the errors when using the thin driver?
You told that there are no errors showing with the oci driver, but nothing about your thin driver attempt.
Showing us the complete error trace will help us to help you.


Also, your insert statement is
insert into Marketing values('team1123','Vimal')
You did not specify column names.
How sure are you that the value 'team1123' is inserted into column customer_id, and not in some other column?

And, in your select, you use this query

select * from Marketing where customer_id='team123'
'team123' is different from the value 'team1123' you inserted. This might explain why the select does not return a row.

Regards, Jan
[ March 18, 2007: Message edited by: Jan Cumps ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic