A
Amit
Hello friends!!
I am new to java and student. I have worte a program in java but some
reason it is not working the way it should do. it is not giving any
error but when i run it is not working properly. so, please help me
out. I have tried so many times to fix it but i could not fix.
Thank you very much
amit
//Here is the code
//main class user has to run this class to get output
import java.io.*;
import java.sql.*;
//import javax.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.lang.String;
import java.lang.*;
class SalaryCount
{
public static void main(String args[])
{
try {
int c = 2;
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
//System.out.println("Please enter number of employee you want to
enter");
//int c = (char) br.read();
//int c = (int) ca;
String empname[] = new String[c];
String emphours[] = new String[c];
String emppay[] = new String[c];
String res[] = new String[c];
//Attempt to load database driver
try
{
// Load Sun's jdbc-odbc driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
}
catch (ClassNotFoundException cnfe) // driver not found
{
System.err.println ("Unable to load database driver");
System.err.println ("Details : " + cnfe);
System.exit(0);
}
// Create a URL that identifies database
String url = "jdbcdbc:COMPUTERUSER/practice/practice2" + args[0];
// Now attempt to create a database connection
Connection db_connection =
DriverManager.getConnection ("url", "amit", "amit");
// Create a statement to send SQL
Statement db_statement = db_connection.createStatement();
for(int i=0; i<c; i++)
{
double value;
System.out.println("Please enter Employee
Name");
empname = br.readLine();
System.out.println("Please enter Employee work
hours");
emphours = br.readLine();
System.out.println("Please enter Employee
Hourly pay");
emppay = br.readLine();
db_statement.executeUpdate ("insert into practice2
values('empname','emphours','emppay')");
//mul ob = new mul();
}
for(int j=0; j<c; j++) {
//res[j] = ob.multiply(emphours[j],
emppay[j]);
System.out.println("Employee Name: " +
empname[j]);
System.out.println("Employee Hours: " +
emphours[j]);
System.out.println("Employee Salary per hour: " +
emppay[j]);
System.out.println("Employee total salary:"
+res[j]);
System.out.println(" ");
}
}catch (Exception e) { }
}
}
I am new to java and student. I have worte a program in java but some
reason it is not working the way it should do. it is not giving any
error but when i run it is not working properly. so, please help me
out. I have tried so many times to fix it but i could not fix.
Thank you very much
amit
//Here is the code
//main class user has to run this class to get output
import java.io.*;
import java.sql.*;
//import javax.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.lang.String;
import java.lang.*;
class SalaryCount
{
public static void main(String args[])
{
try {
int c = 2;
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
//System.out.println("Please enter number of employee you want to
enter");
//int c = (char) br.read();
//int c = (int) ca;
String empname[] = new String[c];
String emphours[] = new String[c];
String emppay[] = new String[c];
String res[] = new String[c];
//Attempt to load database driver
try
{
// Load Sun's jdbc-odbc driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
}
catch (ClassNotFoundException cnfe) // driver not found
{
System.err.println ("Unable to load database driver");
System.err.println ("Details : " + cnfe);
System.exit(0);
}
// Create a URL that identifies database
String url = "jdbcdbc:COMPUTERUSER/practice/practice2" + args[0];
// Now attempt to create a database connection
Connection db_connection =
DriverManager.getConnection ("url", "amit", "amit");
// Create a statement to send SQL
Statement db_statement = db_connection.createStatement();
for(int i=0; i<c; i++)
{
double value;
System.out.println("Please enter Employee
Name");
empname = br.readLine();
System.out.println("Please enter Employee work
hours");
emphours = br.readLine();
System.out.println("Please enter Employee
Hourly pay");
emppay = br.readLine();
db_statement.executeUpdate ("insert into practice2
values('empname','emphours','emppay')");
//mul ob = new mul();
}
for(int j=0; j<c; j++) {
//res[j] = ob.multiply(emphours[j],
emppay[j]);
System.out.println("Employee Name: " +
empname[j]);
System.out.println("Employee Hours: " +
emphours[j]);
System.out.println("Employee Salary per hour: " +
emppay[j]);
System.out.println("Employee total salary:"
+res[j]);
System.out.println(" ");
}
}catch (Exception e) { }
}
}