Results 1 to 2 of 2

Thread: mysql help

  1. #1
    messi_fcb is offline Member
    Join Date
    Mar 2010
    Posts
    1
    Rep Power
    0

    Default mysql help

    hello every one i am new member i am working with mysql in java and i have a problem here i explain it in the code by comment
    Java Code:
    String a="f";
               try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    
            con = DriverManager.getConnection("jdbc:odbc:box",
            "", "");
             myString="create table " + "table" + " (id int unsigned not null auto_increment primary key,"
                    + "sender varchar(50) not null,inbox text(20000) not null)";
            stmt=con.prepareStatement(myString);
    
    //the code execute till here
    
            stmt.executeQuery();///after this statement no statement will execute 
        
    //from here nothing will  execute
    
      myString="insert into  "+"TEtsing"+"box  (sender,inbox) "
                     +" values ('"+a+"','"+a +"');";
            stmt=con.prepareStatement(myString);
            stmt.executeQuery();//
                 }
                 catch(ClassNotFoundException x){}
              catch(SQLException z){}
    and i also use method execute() and executeUpdate() but nothing changed

  2. #2
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    I had to clean up your formatting so that I could make sense of what was going on.
    Java Code:
        String a = "f";
    What is that for?
    Java Code:
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    
            con = DriverManager.getConnection("jdbc:odbc:box", "", "");
            myString = "create table " + "table" + " (id int unsigned not null auto_increment primary key,"
                       + "sender varchar(50) not null,inbox text(20000) not null)";
    You know that this will simply say "create table table (id ..." right? If that second "table" was supposed to be a String, then maybe you want something like "create table '" + table + "' (id ...".
    Java Code:
            stmt = con.prepareStatement(myString);
    
            //the code execute till here
    
            stmt.executeQuery(); // after this statement no statement will execute 
        
            // from here nothing will  execute
    
            myString = "insert into  " + "TEtsing" + "box  (sender,inbox) "
                       + " values ('"+a+"','"+a +"');";
    Similar to above -- you are saying "insert into TEtsingbox (sender..." -- but since execution didn't get there, you haven't seen problems from this yet.
    Java Code:
            stmt = con.prepareStatement(myString);
            stmt.executeQuery(); //
        }
        catch (ClassNotFoundException x) {}
        catch (SQLException z) {}
    Really? You're going to catch those Exceptions and then totally ignore them? No wonder you can't see what problems you are having. Either handle the exceptions and do something useful, or don't catch them at all.

    -Gary-

Similar Threads

  1. SWT and mysql
    By ashin in forum SWT / JFace
    Replies: 4
    Last Post: 07-09-2009, 05:46 AM
  2. MySQL/JDBC Mysql query output
    By thelinuxguy in forum Advanced Java
    Replies: 4
    Last Post: 02-13-2009, 02:57 AM
  3. mySQL HELP!!!
    By ace84 in forum New To Java
    Replies: 0
    Last Post: 04-19-2008, 11:39 PM
  4. Mysql Help
    By Sumendra Maharjan in forum JDBC
    Replies: 1
    Last Post: 08-08-2007, 02:19 AM
  5. JSP and MySQL
    By Ed in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-04-2007, 06:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •