Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java ODBC

Name: Anonymous 2011-04-03 23:00


package homework3;
import java.sql.*;
import javax.swing.JOptionPane;

public class hw3_2 {

    public static void main(String args[])
    {
       
        //Variables for database insert set by JOptionpane data input
        String course = JOptionPane.showInputDialog(null, "Course ID:");
        String desc = JOptionPane.showInputDialog(null, "Description:");
        String cred = JOptionPane.showInputDialog(null, "Credits:");
        int credits = Integer.parseInt(cred);     
       
        //DB Connection
        String url = "jdbc:odbc:registrar";
        Connection con;
        Statement stat;
       
        String insert;
        insert = "INSERT INTO courses VALUES ('" + course + "','" + desc + "','" + credits + "');";
       
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        }
        catch(java.lang.ClassNotFoundException e)
        {
            System.err.print("ClassNotFoundException: ");
            System.err.println(e.getMessage());
        }
       
        try
        {
            con = DriverManager.getConnection(url, "", "");
            stat = con.createStatement();
            ResultSet rs = stat.executeQuery(insert);
            
            System.out.println("Data successfully added to Courses table.");
           
            stat.close();
            con.close();
        }
           
        catch (SQLException ex)
        {
            System.err.println("SQLException: " + ex.getMessage());
        }
    }
}


The insert query works as intended, however I'm getting "SQLException: General error" from the 2nd catch - what error is it catching?

Name: Anonymous 2011-04-04 2:39

>>23
lol.

You want the truth? Truth is, I think Java is a shit language, and all I want to do is solve this small problem and be done with it. I have no intention of arguing with some fuckwit who thinks they're the shit on a shitty 4chan offshoot.

I don't want an "easy grade," as I've said before the program successfully accomplishes what it is meant to do for the assignment. You're simply trying to validate your reason for being a complete asshole, and you're pissed off that I'm not buying it. The fact is, asking for quick help online is easier than reading books and other stupid "learning" methods.

You're dumb to forgo the easy method in favor of the difficult one, as you're clearly deluded into believing that "learning" can only be achieved through the latter. Perhaps you should "learn" that you are ignorant when it comes to such things.

You know, it's funny...I'd wager you're a real piece of shit IRL too.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List