import com.mysql.jdbc.Driver;
import java.sql.*;
/**
* @author fizuli movlamov
*/
public class DBconnect {
public static void main(String[] args) {
try{
DriverManager.registerDriver(new org.gjt.mm.mysql.Driver());
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "123");
Statement araba = connection.createStatement();
ResultSet rs = araba.executeQuery("SELECT * FROM cms_materials");
while(rs.next()){
System.out.println(rs.getInt(1) + " - " + rs.getString(2));
}
rs.close();
} catch (Exception ex) {
System.out.println("Error");
}
}
}
Cok guzel olmus eline saglik.
ReplyDeleteCox sag olun :) Devamli olsun insallah.
Delete