0

I tried to run a simple java program to create a table in oracle Db

My program is

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;


public class lib {
    public static void main(String[]args) throws SQLException,ClassNotFoundException
    {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        Connection conn = DriverManager.getConnection("jdbc:oracle:thin@localhost:1521:xe","scott","tiger");
        Statement st = conn.createStatement();
        st.executeUpdate("Create Table lib(AuthorName varchar2(10),BookName varchar2(10)");
    }

}

while running this program i'm getting the following error

Exception in thread "main" java.sql.SQLException: Invalid Oracle URL specified
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:441)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at lib.main(lib.java:11)

can someone tell me how to fix it?????

i'm using--- web logic server 12c(eclipse-Indigo) & Oracle database 10g XE

My Database is working fine,,but can't able to connect Db using eclipse

Damodaran
  • 10,882
  • 10
  • 60
  • 81
Dinesh
  • 31
  • 5

1 Answers1

0

According to the answer to this question, it appears your connection URL is missing a ':' (column) after ':thin', so your URL should be:

jdbc:oracle:thin:@localhost:1521:xe
Community
  • 1
  • 1
Lolo
  • 4,277
  • 2
  • 25
  • 24
  • Thanks for the replay bro but i tried ur suggestion i'm getting more errors and i think ':' this wont come after "thin" – Dinesh Mar 31 '14 at 08:00
  • @user3395014 According to the Oracle docs, for isntance [here](http://docs.oracle.com/cd/E11882_01/appdev.112/e13995/oracle/jdbc/OracleDriver.html), the ':' is indeed required. Also, "i'm getting more errors" doesn't tell anyone what these errors are and that makes it hard to help. Lastly, I do not think that addressing people as "bro" is going to raise much willingness to help you within the SO community – Lolo Apr 02 '14 at 10:21