Charles Sparking

Greenhorn
+ Follow
since Sep 09, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Charles Sparking

Can anyone help with this exercise i am baffled?




Write a function (or functions) that given a collection of files will produce a sum of integers from each line of each file. Each file can have any number of lines from 1 to N. Each line can contain only one integer and no other alphanumeric characters. All of the numbers from all of the files should be added to the final result. The result is just one number.

For either, what we are looking for is:

1. Clear separation of concerns
2. Well defined objects / interfaces
3. Application of good OO design principles to solve the problem
4. No code duplication
5. Test Driven Development
6. Well refactored code
7. Well tested code
10 years ago
Thanks for taking the time out to reply to me . I appreciate it. I have posted some code below.





import java.io.*;
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class ProductQuery extends JFrame
{
//the attributes
public static final String driver="C:Users.Public.DT Ikemefuna 2 MAR 13.Desktop.PCW Data Backup 10.09.10.Documents and Settings.CHARLES.JCreatorV3LE.MyProjects.Hello.system.RandomFiles.mysql-connector-java-5.0.8.src.org.gjt.mm.mysql.Driver";
public static final String url
="jdbc:mysql://localhost/3306";

public static final String username="U1098765";
public static final String password="scott";

private Connection con;
private Statement st;
private ResultSet result;
private JTextArea display=new JTextArea(25,26);

public ProductQuery()
{
//configure the frame and text area

setTitle("Product query");
add("Center",display);
setSize(520,250);
setVisible(true);
display.setTabSize(16);
display.setFont(new Font("DialogueInput",Font.BOLD,14));

try
{
//load the Mysql jdbc driver
Class.forName(driver);
}
catch(ClassNotFoundException e)
{
display.setText("Driver not found");

}
try
{
//connect to the database
con=DriverManager.getConnection(url,username,password);
//create an SQL statement
st=con.createStatement();
//execute an SQL query
result=st.executeQuery("select *from workers");

//create a handling
display.setText("Serial#"+"\t"+"Make"+"\t"+"Description"+"\t"+"Price"+"\n");
display.append("_____"+"\t"+"____"+"\t"+"_____"+"\t"+"___"+"\n");


//display results
while(result.next())//move to next record
{
//retrieve and display first field
display.append(result.getString(1)+"\t");
//retrieve the second record
display.append(result.getString(2)+"\t");
//retrieve the third record
display.append(result.getString(3)+"\t");
//retrieve the fourth record
display.append(result.getString(4)+"\t");
}
}
catch(SQLException e)//handle the SQL exception
{
e.printStackTrace();

}
}




}


So I am trying to get the information displayed in the GUI. But all I get is a "Driver not found". So it compiles and displays this in the GUI display area. This would be a ClassNotFoundException as the code suggests but I dont understand because when I try to compile the Driver class file.This is the one off the connector/j installation
package com.mysql.jdbc does not exist




package org.gjt.mm.mysql;

import java.sql.SQLException;

/**
* Here for backwards compatibility with MM.MySQL
*
* @author Mark Matthews
*/
public class Driver extends com.mysql.jdbc.Driver {
// ~ Constructors
// -----------------------------------------------------------

/**
* Creates a new instance of Driver
*
* @throws SQLException
* if a database error occurs.
*/
public Driver() throws SQLException {
super();
}
}
This will not allow me to connect to the mysql database which i have installed on my computer.In addition I have installed connector/j into the same directory. I have opened the class driver that resides in the org.gjt.mm.mysl folder in my IDE (Jcreator) and i have placed in the same directory with my ProductQuery class.
What I am actually trying to achieve is I have 2 input files that I require a java program to read and populate the tables. cam anyone help. see the question below

Please complete the Java exercise below.

Assumptions and prerequisites for this project:
- There exist a database with following two tables:
o PERSON [ PERSON_ID (Primary Column), LAST_NAME, FIRST_NAME, STREET, CITY ]
o ORDER [ ORDER_ID (Primary Column), ORDER_NO, PERSON_ID ]
- Input files to be processed:
o Person.data – The file has Person ID, First Name, Last Name, Street, City separated by comma (‘,’).

o Order.data – The file Order ID, Order Number and Person ID separated by pipe (‘I’) character. Person ID is present in both the files.


Requirement - Write a Java program to:
- Read the files (Person.data and Order.data) and populate the tables (PERSON and ORDER)
- Fetch data from these two database tables (using plain JDBC) and print:
o Persons with at least one Order
o All Orders with First Name of the corresponding person (if available)

Artefacts to be submitted at the end of this exercise:
- A zipped version of the source code with a project summary write up.

Mandatory requirements:
- Java 5 or above should be used.
- No third party libraries other than JDBC and JUnit
- The unzipped project files should be portable to a standard IDE such as Eclipse or NetBeans

The project work will be evaluated based on:
- Usage of Java coding standards
- Usage of control statements (if, for, while, switch, etc.), Collection API
- Utilisation of OOPs concepts
- Efficiency of the code
- Exception Handling
- Usage of Design Patterns
- Test Cases (preferably in JUnit)



I tried to use some indentation to make it clearer but i guess it doesnt show that. but anyways java sourcefiles inside that are folders Chapter05-Chapter24. Chapter06 has 3 files on it Oblong, easyScanner and bankaccount. These are the classes that am trying to get to compile.
11 years ago
yes they are java source files

the structure is as follows
11 years ago
basically these classes are on a cd and i have to copy them to the correct directory for the compiler to access them but i have i dont kno what am doing wrong??
11 years ago
import java.util.*;
public class oblongTester
{
public static void main(String[]args)
{
Scanner sc=new Scanner(System.in);
/*declare two variables to hold the length and height
*of the oblong as input by the uaer*/
double oblongLength, oblongHeight;

//declare a reference to an oblong object
Oblong myOblong;
//now get the values fromn the user
System.out.print("Please enter the length of your oblong");
oblongLength=sc.nextDouble();
System.out.print("Please enter the height of your oblong");
oblongHeight=sc.nextDouble();
//create a new oblong object
myOblong=new oblong(oblongLength,oblongHeight);
/*use the variousmethods of the oblong class to display
*the length, height, area and perimeter of the oblong*/
System.out.println("Oblong length is "+ myOblong.getLength());
System.out.println("oblong height is "+myOblong.getHeight());
System.out.println("oblong area is "+myOblong.calculateArea());
System.out.println("oblong perimeter is "
+myOblong.calculatePerimeter());

errors: cannot find symbol class oblong line 12
class oblong is public should be declared in a file named oblong.java line 1
cannot access oblong line 19
11 years ago
How do I use or gain access to the oblong class, bankAccount class and the easyScanner class in Jcreator?I am using Java in two semesters by charatan & Kans the second edition and am on chapter 6 classes and objects i cant seem to get any of these to compile...can anyone please help its really urgent?
11 years ago

Lexington Smith wrote:

Charles Sparking wrote:Can any junior java developers give me an indepth description of what you do at work everyday


Boss gives me a small job because i am a beginner. I do the job...he gives me more. I do that too, then i get a more complicated job....
thats how it went for me.




what exactly did this small jobs entail and what techical java elements did you make use of methods, arrays, objects etc.would these jobs be tested by potential clients.
11 years ago
Can any junior java developers give me an indepth description of what you do at work everyday
11 years ago