Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String cname = request.getParameter("cname");
- try{
- // Register JDBC driver
- Class.forName("com.mysql.jdbc.Driver");
- // Open a connection
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/infoshare", "root", "");
- // Execute SQL query
- Statement stmt = conn.createStatement();
- String sql;
- sql = "INSERT INTO catagory(Catagory_name) VALUES("+cname+")";
- //ResultSet rs = stmt.executeQuery(sql);
- //out.print(cname);
- stmt.executeUpdate(sql);
- out.print("<h1>Hello</h1>");
- // Clean-up environment
- //rs.close();
- stmt.close();
- conn.close();
- }catch(SQLException se){
- //Handle errors for JDBC
- se.printStackTrace();
- }catch(Exception e){
- //Handle errors for Class.forName
- e.printStackTrace();
- }
Add Comment
Please, Sign In to add comment