Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.portlet;
- import java.sql.*;
- public class Test {
- public static void main(String[] args) {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch(ClassNotFoundException e) {
- System.out.println("Class not found "+ e);
- }
- System.out.println("JDBC Class found");
- int no_of_rows = 0;
- try {
- Connection con = DriverManager.getConnection (
- "jdbc:mysql://localhost/odpadki","root", "Cuftek!234");
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery ("SELECT * FROM mapa");
- while (rs.next()) {
- no_of_rows++;
- }
- System.out.println("There are "+ no_of_rows + " record in the table");
- } catch(SQLException e){
- System.out.println("SQL exception occured" + e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement