Results 1 to 12 of 12

Thread: netbeans

  1. #1
    Nishanthi is offline Member
    Join Date
    Sep 2009
    Posts
    7
    Rep Power
    0

    Exclamation netbeans

    right now i m working in netbeansIDE with web application i m trying to connect to sql server 2005 database using the preceding coding


    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:data");
    Statement st=con.createStatement();
    st.executeUpdate("insert into audio values(11)");
    con.close();
    st.close();


    now no data are inserted int the audio table what is the solution for this.Its windows authentication i m using in Sql server 2005 pls help me to solve this

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    9

    Default

    Did you get an exception? What was the return value of the executeUpdate method?

  3. #3
    Nishanthi is offline Member
    Join Date
    Sep 2009
    Posts
    7
    Rep Power
    0

    Exclamation netbeans

    in the sqlserver 2005 the record was not inserted

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    9

    Default

    You did not answer any of the questions I posted above.

  5. #5
    Nishanthi is offline Member
    Join Date
    Sep 2009
    Posts
    7
    Rep Power
    0

    Exclamation

    thr was no return type... the record didnt insert into database.... i didnt get any exception..........

  6. #6
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    7

    Default

    Is there any issue with the connection better to say is the connection successful, or its not just inserting the record?

  7. #7
    marcellis is offline Member
    Join Date
    Sep 2009
    Posts
    12
    Rep Power
    0

    Default

    Try to insert the record on database level, maybe you get more information about the error

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,474
    Rep Power
    21

    Default

    Post your proper code, including the try/catch block surrounding it.
    Whatever is wrong is probably in code you're not showing us.

  9. #9
    Nishanthi is offline Member
    Join Date
    Sep 2009
    Posts
    7
    Rep Power
    0

    Exclamation netbeans

    import java.io.*;
    import java.net.*;

    import javax.servlet.*;
    import javax.servlet.http.*;

    /**
    *
    * @author Owner
    * @version
    */
    public class NewServlet extends HttpServlet {

    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try
    {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:data");
    Statement st=con.createStatement();
    st.executeUpdate("insert into audio values(11)");
    con.close();
    st.close();
    }
    catch(Exception e)
    {
    }
    }

  10. #10
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    10

    Default

    No wonder you're "not getting any exception".
    Quote Originally Posted by Nishanthi View Post
    catch(Exception e)
    {
    }
    Don't do that, ever.

    Add e.printStackTrace() (at a minimum) to that catch block. How are you ever going to know what is going wrong when you are ignoring the errors?
    Last edited by masijade; 10-02-2009 at 09:41 AM.

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,474
    Rep Power
    21

    Default

    That's what I thought...
    Do as masijade suggests, and find out what exception is being thrown.

  12. #12
    atom86 is offline Member
    Join Date
    Sep 2009
    Location
    Italy, Turin
    Posts
    39
    Rep Power
    0

    Default

    Masi has a point.....and if you want my opinion, i suggest you to catch an SQLException instead than a general Exception.... an Exception could be EVERYTHING... nullPointer... IndexOutOfBound...... Heap Memory Error... FileNotFound... BadFileDescriptor... and more.........[...]

    So in this case it's better if you catch an SQLException because connecting to a DB and executing a query is the most important operation you do in this part of your code.. and probably (probably not sure) one of this 2 instruction can throw an SQLException.. in this situation

Similar Threads

  1. help with netBeans
    By the godfather01 in forum NetBeans
    Replies: 11
    Last Post: 02-01-2009, 05:48 PM
  2. Need Help in Netbeans please
    By Akora in forum New To Java
    Replies: 3
    Last Post: 01-21-2009, 06:43 PM
  3. NetBeans IDE 6.5 - The only IDE you need
    By Eranga in forum Reviews / Advertising
    Replies: 2
    Last Post: 11-26-2008, 10:37 AM
  4. netbeans
    By sweet angle in forum NetBeans
    Replies: 1
    Last Post: 08-05-2008, 04:06 AM
  5. NetBeans 5.5
    By Ry4n in forum NetBeans
    Replies: 3
    Last Post: 01-26-2008, 07:09 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
  •