|
|
| 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(); } } }
----------------------------------------
Read for more information.
http://www.roseindia.net/jdbc/
Thanks.
|
| More Questions |
|
|
Post Answers
Ask Question
Facing Programming Problem?
|
|
|
|
|