Re: getting mysql-data with jconnector

From: codemaster (jod_at_doe.com)
Date: 12/17/04


Date: Fri, 17 Dec 2004 17:25:32 +0200

this wont work, why?

public class Jdbctesti {
 public static void main(String[] args) {
  try {
   Class.forName("com.mysql.jdbc.Driver").newInstance();
   Connection conn =
DriverManager.getConnection("jdbc:mysql://linkille.com/linkille_linkillecom?user=linkille_tuomaz&password=ckbebeck");
   getData(conn);
   System.out.println("works");
  } catch (Exception ex) {
   ex.printStackTrace();
  }
 }

 public static void getData(Connection conn) {
  try {
   Statement stmt = null;
   ResultSet rs = null;
   stmt = conn.createStatement();
   String query = "SELECT foo FROM bar ORDER BY baz";
   rs = stmt.executeQuery(query);
  } catch (Exception e) {}
 }
}

"codemaster" <jod@doe.com> kirjoitti
viestissä:0FCwd.1218$bw2.810@reader1.news.jippii.net...
> what should i put to the getData() method to get some data?
>
> public class Jdbctesti {
> public static void main(String[] args) {
> try {
> Class.forName("com.mysql.jdbc.Driver").newInstance();
> Connection conn = DriverManager.getConnection("jdbc:mysql://host");
> getData();
> } catch (Exception ex) {
> ex.printStackTrace();
> }
> }
>
> public static void getData() {
> // prints SELECT-result to command line
> }
> }
>



Relevant Pages

  • Re: Sending email
    ... I'm even newer to programming email ... using whatever arguments it needs -- uses sendEmail ... line throws an exception, your mailmenssage will never be disposed of. ... public static void forgotPassword ...
    (microsoft.public.dotnet.languages.csharp)
  • How to get the value of an attribute in an XML node?
    ... of an xml file that I am trying to read and get the values of the ... XMLEventReader r = factory.createXMLEventReader; ... catch (Exception ex) ... public static void getGeneRecord{ ...
    (comp.lang.java.databases)
  • Re: Is It Possible to Make Java Find a File on Your Computer?
    ... The fact that Desktop respects local behavior associations makes it most ... public static void mainthrows Exception { ... public class FileAssociation { ...
    (comp.lang.java.programmer)
  • How to get the info from the database
    ... XMLEventReader r = factory.createXMLEventReader; ... catch (Exception ex) ... public static void getGeneRecord(String geneid) { ...
    (comp.lang.java.gui)
  • How to get the info from the database
    ... XMLEventReader r = factory.createXMLEventReader; ... catch (Exception ex) ... public static void getGeneRecord(String geneid) { ...
    (comp.lang.java.databases)