السلام عليكم ..
هذا كود الاتصال مع قاعدة بيانات MySql ...
ملاحظة لازم تضيف الباكج للدرايفر اللي يخليك تتصل مع MySql ..
import java.sql.*;
public class mysql {
public static void main(String []args) throws Exception{
Class.forName("org.gjt.mm.mysql.Driver");/* this is the driver from the package*/
Connection c = DriverManager.getConnection("jdbc:mysql://localhost/mysql","username","password");
Statement st = c.createStatement();
boolean bo = st.execute("use Mysql;");
ResultSet rs =st.executeQuery("select * from user;");
while (rs.next()) {
System.out.println(rs.getString("user")+" and password= "+rs.getString("password"));
}
}
}بالنسبة للباكج .. اذا كنت تستخدم jcreator قم بعمل الاتي ..
روح لقائمة configure بعدين options بعدين jdk profile بعدين Edit بعدين Add Archive واختار الباكيج المرفقة مع هذا الموضوع ...