fork(3) download
  1. package dbms_basic;
  2. import java.sql.*;
  3. public class Dbms_Basic {
  4.  
  5.  
  6. public static void main(String[] args) {
  7. // TODO code application logic here
  8. Connection con=null;
  9. Statement stmt=null;
  10. String url="jdbc:mysql://localhost:3306/student";
  11. String user="root";
  12. String pass="system";
  13. try {
  14. Class.forName("com.mysql.jdbc.Driver");
  15.  
  16. System.out.println("Now connecting to databse...\n");
  17. con=DriverManager.getConnection(url,user,pass);
  18. System.out.println("Connected !!!\n");
  19. stmt=con.createStatement();
  20. System.out.println("Asking for query...\n");
  21. ResultSet rs=stmt.executeQuery("select * from cse");
  22. System.out.println("we got it !!!\n");
  23. System.out.println("Time to display it...\n");
  24. while(rs.next())
  25. {
  26. System.out.println(rs.getInt(1)+" "+rs.getString(2));
  27.  
  28. }
  29. System.out.println("ok it's done !!!\n");
  30. stmt.close();
  31. con.close();
  32. System.out.println("connection close !!!\n");
  33.  
  34. } catch (ClassNotFoundException | SQLException e) {System.out.println(e);}
  35.  
  36. }
  37. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: class Dbms_Basic is public, should be declared in a file named Dbms_Basic.java
public class Dbms_Basic {
       ^
1 error
stdout
Standard output is empty