| | |
java connectivity
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
"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
Views: 336 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Java
actionlistener android api apple applet application arguments array arrays automation binary bluetooth character chat class classes client code component consumer database desktop detection draw eclipse encode error event exception file fractal ftp game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me java javac javaee javaprojects jmf jni jpanel julia linked linux list loop mac map method methods mobile netbeans newbie number object online oracle os print printf problem program programming project properties recursion researchinmotion rotatetext rsa scanner score screen server set size sms socket sort sql string swing template test threads time transfer tree update windows working xstream






