السلام عليكم
أخواني في منتدى الجافا
قمت بعمل كلاس يقوم بالاتصال بقاعدة بيانات من نوع Mysql
وعند تنفيذه يعطي خطأ
Access denied for user 'xxxxx'@'94.98.58.230' (using password: YES)
مع العلم لو قمت بوضع هذه الابي يقوم بالاتصال بقاعدة البيانات
ويعطي نتائج صحيح
وطبعا من المستحيل انك تضيف كل الايبي في الدنيا علشان يشتغل البرنامج
الشيفرة هي
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DataBase;
/**
*
* @author engali
*/
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;
public class ConnctionDataBase {
public static String userid="xxx", password = "pppppp";
public static final String JDBC_Driver="sun.jdbc.odbc.JdbcOdbcDriver";
public static final String url = "jdbc:mysql://xxxxx.com/abcdd?";
Connection con = null;
public Connection CreateConnection(){
try {
Class.forName(JDBC_Driver);
System.out.println("connection is ok");
}
catch(java.lang.ClassNotFoundException e) {
System.out.println("connection is ok2");
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url, userid, password);
con.setAutoCommit(false);
System.out.println("connection is ok3");
}
catch(SQLException ex) {
//System.err.println("SQLException: " + ex.getMessage());
ex.printStackTrace();
}
return con;
}
public void closeConnection() throws SQLException{con.close();System.out.println("connection is close");}
public static void main(String arg[]) throws SQLException
{
ConnctionDataBase dd=new ConnctionDataBase();
long startTime = System.currentTimeMillis();
Statement stmt= dd.CreateConnection().createStatement();
ResultSet rs = stmt.executeQuery("Select * from price ");int i=0;
while(rs.next())
{
System.out.println("ss"+""+i++);
}// end while
long endTime = System.currentTimeMillis();
System.out.println("Total elapsed time in execution of method callMethod() is :"+ (endTime-startTime)+" Millis");
dd.closeConnection();
}
}في هل من مساعدة لموضع الايبي
تحياتي
