for example... i have 3 files... java update 2- 3 and 5.... is it ok to delete 2 and 3 since i would still have 5??
My blackberry pearl has been trying to open a page with java script for about ten minutes now. i want it to stop because its slowing my whole phone down but it is frozen. it hasn t made any progress in downloading. I ve tried restarting my phone- going to a different sit- pressing the stop and going on the help page but nothing helps! please help me i don t know what do to!
How hard is to get a job with an Associate Degree in Computer Science??
I will be finishing up my Associate Degree in Computer Science in Dec of 08. I am currently doing an internship with a major cooperation- and have been since last month. I know SQL and PL/SQL- and am finshing up my Java courses in school ( Although I dont like Java at all). Right now I am working with the help desk- next month I am supposed to be working with the DBA learning some stuff there as well.
Basically I am doing Oracle reports right now- and using Developer to code in.
Your imput would be greatly appreciated. I have put this question up before- but havent gotten any solid- usefull answers.
Thanks in advance
Sorry for the repeat- i have found a way to fit in all the code.
First class with the connection is
import java.util.*;
import java.sql.*;
public class DatabaseUtils
{
String driver = "oracle.jdbc.driver.OracleDriver";
public static Connection con(String driver- String url- String username- String password)
throws ClassNotFoundException- SQLException
{
Class.forName(driver);
return DriverManager.getConnection(url- username- password);
}
// Similar methods to close Statement and ResultSet
public static void close(Connection connection)
{
try
{
if (connection != null)
{
connection.close();
}
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
My second class needs to use this con method to get a connection.
Second class
import java.util.*;
import java.sql.*;
public class PersonDAO{
public static void main(String args[])
{
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@localhost:1521:XE";
String userName = "nick";
String passWord = "hello";
PersonInfo person = new PersonInfo();
DatabaseUtils.con(driver- url- userName- passWord);
try
{
String sql = "INSERT INTO Person(name- idNo- " +
"userName- passWord) VALUES (?-?-?-?) ";
// Create a Preparedstatement
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1- person.getName());
ps.setString(2- person.getIdNo());
ps.setString(3- person.getUsername());
ps.setString(4- person.getPassword());
ps.executeUpdate();
}
catch(Exception e){
System.out.println(e);
}
}
}// end class PersonDAO
I am getting the error in this class saying cannot find symbal variable con- relating too the line
PreparedStatement ps = con.prepareStatement(sql);
I am not sure if i am parseing it correctly (well- obviously i am not). Can you see what i have done wrong? P.S the class name is irrelivant here- i am not producing a DOA.
I have two classes. The first on creates a connection.
public class DatabaseUtils
{
String driver = "oracle.jdbc.driver.OracleDriver";
public static Connection con(String driver- String url- String username- String password)
throws ClassNotFoundException- SQLException
{
Class.forName(driver);
return DriverManager.getConnection(url- username- password);
}
In the second one i am trying to use the con method. This is my attempt.
public static void main(String args[])
{
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@localhost:1521:XE";
String userName = "scott";
String passWord = "tiger";
PersonInfo person = new PersonInfo();
DatabaseUtils.con("<driver>"- "<url>"- "<userName>"- "<passWord>");
(not all code included). This wont work at the moment- what have i done wrong?
cheers
The connection is all fine. In the second class i have above- underneath this i have
try
{
String sql = "INSERT INTO Person(name- idNo- " +
"userName- passWord) VALUES (?-?-?-?) ";
// Create a Preparedstatement
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1- person.getName());
ps.setString(2- person.getIdNo());
ps.setString(3- person.getUsername());
ps.setString(4- person.getPassword());
ps.executeUpdate();
}
catch(Exception e){
System.out.println(e);
}
The error is coming back to this saying cannot find symbal variable con
PreparedStatement ps = con.prepareStatement(sql);
I was trying to add all my code but i couldnt fit it all in cos of the 1000 limit.
No comments:
Post a Comment