Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am having great difficulty making a connection to an Oracle Database OJDBC.
I´m using Google Web Toolkit and i added a SQL Database to my project. The Database name is Agenda.

I've searched a lot, it seems this problem is common to many people, but could not overcome this problem. I've downloaded "ojdbc6.jar" and added to my BUILDPATH. I've refreshed, close, open and reopen, but I still see errors.

My Specs: Windows 7 x64 Springsource - tried also in Eclipse Database - Oracle 10.2.0 and the database is attached to my source project under com.gwt.agenda

private static final long serialVersionUID = 1L;
private Connection connection = null;
private Properties props = null;
private ClassLoader cl = null;
private String databaseURL = "";
private String databaseUser = "";
private String databasePass = "";
public void init() {
    try {
        // Load the database connection properties from com.gwt.agenda.GWTAgendaSample.properties
        props = new Properties();
        cl = this.getClass().getClassLoader();
        InputStream is = cl.getResourceAsStream("com/gwt/agenda/GWTAgendaSample.properties");
        props.load(is);
        // Load the database access information
        databaseURL = props.getProperty("databaseURL");
        databaseUser = props.getProperty("databaseUser");
        databasePass = props.getProperty("databasePass");
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("Error loading GWTAgendaSample.properties file.", e);
    }
    try {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        // Connect to the database
        connection = DriverManager.getConnection(databaseURL, databaseUser, databasePass);
    } catch (SQLException se) { messageOut = "Unable to connect to database. Exception message: " + se.getMessage();
        System.out.println(messageOut);
        se.printStackTrace();
        // Server side log
        logger.error(messageOut + "\n", se);
        destroy();
    } catch (Exception e) {
        messageOut = "Unable to connect to database. Exception message: " + e.getMessage();
        System.out.println(messageOut);
        e.printStackTrace();
        // Server side
        logger.error(messageOut + "\n", e);
        destroy();
    }
}

ERROR
Unable to connect to database. Exception message: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

databaseURL=jdbc:oracle:thin:@hp-PC:1521:xe databaseUser=user databasePass=agenda Where @hp-PC is my computer name

Can someone point me in the right direction. Am i missing something?

Please help!

share|improve this question

1 Answer 1

change your computer name to host in listner.ora file and tnsname.ora file where ur oracle installed folder such as db_1-network-admin-you will get .ora file and change your host to 127.0.0.1 if yours is local machine,and port to 1521.. try this out

and xe you mentioning it should be your sid,,check this also

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.