help with inserting text into a database
hello
i have this code but i want to be able to insert into the database could someone please adjust my code so it works please
does it matter what i insert into the database?
import java.sql.*;
public class CoalTotals {
public static void main(String[] args) {
String data = "jdbc:odbc:myProject";
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection(
data, "", "");
Statement st = conn.createStatement();
ResultSet rec = st.executeQuery(
"SELECT * " +
"FROM Coal " +
"WHERE " +
"(Country='" + args[0] + "') " +
"Order by Year");
System.out.println("Fips\tCountry\tYear\t" +
"Anthracite production");
while(rec.next()) {
System.out.println(rec.getString(1) + "\t"
+ rec.getString(2) + "\t"
+ rec.getString(3) + "\t"
+ rec.getString(4));
}
st.close();
} catch (SQLException s) {
System.out.println("SQL Error: " + s.toString() + " "
+ s.getErrorCode() + " " + s.getSQLState());
} catch (Exception e) {
System.out.println("Error: " + e.toString()
+ e.getMessage());
}
}

