8 Years
Discussion Span
Last Post by stephen84s

I have to make a database in oracle and connect it with Java. But I'm not able to do so.
Please help.

I want to make a space ship and fly back to my home on Mars, please help me too.


sorry stephen84s for unclearity in my question,
But the problem is I've crated the database using Oracle8i.But now I don't know what to do next.


My code is:-

import java.sql.*;

import java.io.*;

public class dbcon{

public static void main(String[] args) {

Connection connection = null;

try {

// Load the JDBC driver

String driverName = "oracle.jdbc.driver.OracleDriver";


// Create a connection to the database

//String serverName = "";

//String portNumber = "1521";

//String sid = "oracle";

String url = "jdbc:oracle:thin:@//local.server:1521/oracle";

String username = "scott";

String password = "tiger";

connection = DriverManager.getConnection(url, username, password);

System.out.println("***Connected to the database***");

} catch (ClassNotFoundException e) {

// Could not find the database driver

} catch (SQLException e) {

// Could not connect to the database



The compilation error whichI'm getting is:
The pointer has reached at the end of line while parsing} ->

Edited by happygeek: fixed formatting


As error message states you missing closing bracket "}" on the end of your code. If you check your code you will find that main() was closed, however you did not do same for the class


Peter has already mentioned the cause of your problem, now just wanted to add a few notable things like :-

  1. You never closed your connection, Its important to close your database connection once you are done using it. Preferably put the call to close() inside a finally block, so that your database connection is closed irrespective of whether an SQLException was thrown during your query execution etc.
  2. In the catch block where you have caught your SQLException always print / log the SQL State by calling e.getSQLState(), by comparing the SQL State with your DBMS vendor data example here, you can map out exactly why your query failed.
Votes + Comments
Well spotted
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.