|
|
| jdbc |
Expert:Ramakrishna
jdbc Expert:Ramakrishna Statement st1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet rs10=st1.executeQuery("select * from subfac"); while (rs10.next()) { if(t.equals(rs10.getString(3))) { String sub=rs10.getString(1); String fac=rs10.getString(2); String subfac=sub+fac; d.println(subfac); st1.executeUpdate("delete from tab where year='"+rs10.getSring(3)+"'");
st1.executeUpdate("drop table "+subfac); } } rs10.close(); here i want to drop table and delete some values from table;
" here rs10.getString(1) " is the only primary key
solve this problem.. how to drop and delete values from table
thank y sir Answers Hi friend,
Please implement following code.
import java.sql.*;
public class DeleteTable{ public static void main(String[] args) { System.out.println("Tabel Deletion Example"); Connection con = null; String url = "jdbc:mysql://localhost:3306/";; String dbName = "jdbctutorial"; String driverName = "com.mysql.jdbc.Driver"; String userName = "root"; String password = "root"; try{ Class.forName(driverName).newInstance(); con = DriverManager.getConnection(url+dbName, userName, password); try{ Statement st = con.createStatement(); st.executeUpdate("DROP TABLE Employee"); System.out.println("Table Deletion process is completly successfully!"); } catch(SQLException s){ System.out.println("Table is not exists!"); } con.close(); } catch (Exception e){ e.printStackTrace(); } } }
hey here i want to romove using ResultSet. Did u read my question or not.. dont send the roseindia examples okk see the problem clearyly |
| Answers |
Hi friend,
What you means this line.
((i want to drop table and delete some values from table;))
At a time you can do one work.
first time you can drop ya first time you can do delete. so please what is your problem please send me clear.
Because alway you are post short code and description.
Thanks.
|
| More Questions |
|
|
Post Answers
Ask Question
Facing Programming Problem?
|
|
|
|
|