| | |
java connectivity
![]() |
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
@coolbuddy059 please provide your current code so we may have look at it and correct it if there is any issue
PS:In the future please provide more info, if you wish to avoid general suggestions such as one by stephen. Secondly we have rule that says "We only give homework help to those who show effort"
PS:In the future please provide more info, if you wish to avoid general suggestions such as one by stephen. Secondly we have rule that says "We only give homework help to those who show effort"
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Aug 2008
Posts: 40
Reputation:
Solved Threads: 0
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";
Class.forName(driverName);
// Create a connection to the database
//String serverName = "127.0.0.1";
//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} ->
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";
Class.forName(driverName);
// Create a connection to the database
//String serverName = "127.0.0.1";
//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} ->
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
Last edited by peter_budo; Mar 31st, 2009 at 8:10 am.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Peter has already mentioned the cause of your problem, now just wanted to add a few notable things like :-
- 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.
- 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.
Last edited by stephen84s; Apr 1st, 2009 at 1:35 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
![]() |
Similar Threads
- Sybase & java Connectivity (Java)
- Java Tutorials (Java)
- database connectivity in vc++ 6.0 (C++)
- Xml Database Connectivity in Java (Java)
- Java newbie (Java)
- Internet Connectivity online for 10 minutes... (Viruses, Spyware and other Nasties)
Other Threads in the Java Forum
- Previous Thread: Java system info
- Next Thread: Send SMS
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress input integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle physics plazmic print problem program programming project recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree trolltech unlimited utility webservices windows






