I tried to connect to a MySQL database in java in eclipse but I have this error when I run my program:
URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "pa"
Here is my code:
public static void main(String[] args) {
try {
Connection con=null;
Statement stm=null;
ResultSet resultSet=null;
String host = "localhost:3306";
String db = "mysqlconn";
String driver = "com.mysql.jdbc.Driver";
String user = "newuser";
String pass = "123456";
Class.forName(driver).newInstance();
//String result = java.net.URLDecoder.decode(, "UTF-8");
con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/myslconn?user=root%password=123456");
stm = ((java.sql.Connection) con).createStatement();
String sorgu = "SELECT * FROM mysqlconn";
resultSet = stm.executeQuery(sorgu);
while(resultSet.next()) {
System.out.println(resultSet.getString("id"));
//System.out.println(resultSet.getString("marka"));
}
}
catch(Exception ex) {
System.err.println("Hata ! ");
System.err.println(ex.getMessage());
}
}