inkedmn
10-25-2002, 03:38 AM
alright, i've been screwing around with this for about the past 3 hours now, and i'm about ready to set fire to this machine.
so please help me :)
ok, here's my code:
import java.sql.*;
public class Database {
private String host = "localhost";
private String user = "dbuser";
private String pass = "dbuser";
private String dbname = "joana";
private String url = "jdbc:mysql:joana";
protected Connection c;
protected Statement stmt;
public Database() {
Class.forName("org.gjt.mm.mysql.Driver");
c = DriverManager.getConnection(url, user, pass);
stmt = c.createStatement();
}
protected String insertFactoid(String key, String value, String sender) {
try {
stmt.executeUpdate("INSERT INTO FACTOID " +
"VALUES (" + key + " ," + value + " ." + sender + ") ");
return "ok";
} catch (Exception sqlex) {
return "there was a problem. tell inkedmn what you typed";
}
}
public static void main(String[] args) {
Database db = new Database();
String out = db.insertFactoid("test", "testing factoid db", "inkedmn");
System.out.println(out);
}
}
and here are my compiler errors...
D:\development\java_practice\myjava\joana>javac Database.java
Database.java:36: incompatible types
found : java.sql.Connection
required: Connection
c = DriverManager.getConnection(url, user, pass);
^
Database.java:37: cannot resolve symbol
symbol : method createStatement ()
location: class Connection
stmt = c.createStatement();
^
2 errors
i've followed the jdbc tutorial to the freakin' letter. all i know is, the docs say to use the createStatement() method, but it's not in the documentation under the Connection interface.
and the first error is a complete mystery to me...
HELP!
thanks :)
so please help me :)
ok, here's my code:
import java.sql.*;
public class Database {
private String host = "localhost";
private String user = "dbuser";
private String pass = "dbuser";
private String dbname = "joana";
private String url = "jdbc:mysql:joana";
protected Connection c;
protected Statement stmt;
public Database() {
Class.forName("org.gjt.mm.mysql.Driver");
c = DriverManager.getConnection(url, user, pass);
stmt = c.createStatement();
}
protected String insertFactoid(String key, String value, String sender) {
try {
stmt.executeUpdate("INSERT INTO FACTOID " +
"VALUES (" + key + " ," + value + " ." + sender + ") ");
return "ok";
} catch (Exception sqlex) {
return "there was a problem. tell inkedmn what you typed";
}
}
public static void main(String[] args) {
Database db = new Database();
String out = db.insertFactoid("test", "testing factoid db", "inkedmn");
System.out.println(out);
}
}
and here are my compiler errors...
D:\development\java_practice\myjava\joana>javac Database.java
Database.java:36: incompatible types
found : java.sql.Connection
required: Connection
c = DriverManager.getConnection(url, user, pass);
^
Database.java:37: cannot resolve symbol
symbol : method createStatement ()
location: class Connection
stmt = c.createStatement();
^
2 errors
i've followed the jdbc tutorial to the freakin' letter. all i know is, the docs say to use the createStatement() method, but it's not in the documentation under the Connection interface.
and the first error is a complete mystery to me...
HELP!
thanks :)