Results 1 to 12 of 12
Thread: netbeans
- 09-29-2009, 06:42 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 7
- Rep Power
- 0
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
- 09-29-2009, 06:51 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Did you get an exception? What was the return value of the executeUpdate method?
- 09-30-2009, 07:20 AM #3
Member
- Join Date
- Sep 2009
- Posts
- 7
- Rep Power
- 0
netbeans
in the sqlserver 2005 the record was not inserted
- 09-30-2009, 08:09 AM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
You did not answer any of the questions I posted above.
- 10-01-2009, 11:28 AM #5
Member
- Join Date
- Sep 2009
- Posts
- 7
- Rep Power
- 0
thr was no return type... the record didnt insert into database.... i didnt get any exception..........
- 10-01-2009, 11:31 AM #6
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
Is there any issue with the connection better to say is the connection successful, or its not just inserting the record?
- 10-01-2009, 02:17 PM #7
Member
- Join Date
- Sep 2009
- Posts
- 12
- Rep Power
- 0
Try to insert the record on database level, maybe you get more information about the error
- 10-01-2009, 02:21 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Post your proper code, including the try/catch block surrounding it.
Whatever is wrong is probably in code you're not showing us.
- 10-02-2009, 07:45 AM #9
Member
- Join Date
- Sep 2009
- Posts
- 7
- Rep Power
- 0
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-02-2009, 08:10 AM #10
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
- 10-02-2009, 09:04 AM #11
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
That's what I thought...
Do as masijade suggests, and find out what exception is being thrown.
- 10-02-2009, 09:29 AM #12
Member
- Join Date
- Sep 2009
- Location
- Italy, Turin
- Posts
- 39
- Rep Power
- 0
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
-
help with netBeans
By the godfather01 in forum NetBeansReplies: 11Last Post: 02-01-2009, 04:48 PM -
Need Help in Netbeans please
By Akora in forum New To JavaReplies: 3Last Post: 01-21-2009, 05:43 PM -
NetBeans IDE 6.5 - The only IDE you need
By Eranga in forum Reviews / AdvertisingReplies: 2Last Post: 11-26-2008, 09:37 AM -
netbeans
By sweet angle in forum NetBeansReplies: 1Last Post: 08-05-2008, 04:06 AM -
NetBeans 5.5
By Ry4n in forum NetBeansReplies: 3Last Post: 01-26-2008, 06:09 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks