Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class Baza{
- public static void main(String[] args) {
- Connection conn = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- conn = DriverManager.getConnection("jdbc:mysql://localhost/ksiegarnia","root","");
- Statement sqlState = conn.createStatement();
- String selectStuff = "Select klienci.imie,klienci.nazwisko FROM klienci,zamowienia ";
- ResultSet rows = sqlState.executeQuery(selectStuff);
- int i=0;
- while(rows.next()){
- System.out.println(rows.getString("imie")+" "+rows.getString("nazwisko"));
- i++;
- }
- System.out.println(i);
- }
- catch (SQLException ex) {
- System.out.println("SQLException: " + ex.getMessage());
- System.out.println("VendorError: " + ex.getErrorCode());
- }
- catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement