Skip navigation links

MySQL Forums :: Connector/JDBC and Java :: problem with the connector


Advanced Search

problem with the connector
Posted by: panos karakontakis ()
Date: January 20, 2011 11:56AM

Hi i import the jar file mysql-connector-java-5.1.14-bin into the libraries but still the error message appears.

Couldn't connect: print out a stack trace and exit.
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown character set: 'utf8mb4'

Some help would be nice. Here is my code.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class MySQL_Connection {

public MySQL_Connection()
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException cnfe) {
System.err.println("Couldn't find driver class:");
cnfe.printStackTrace();
}

Connection c = null;

try {
c = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/panos","root", "dei");

} catch (SQLException se) {
System.out.println("Couldn't connect: print out a stack trace and exit.");
se.printStackTrace();
System.exit(1);
}
/////////////////////////////////////////////////////////////////////

Statement s = null;
try {
s = c.createStatement();
} catch (SQLException se) {
System.out.println("We got an exception while creating a statement:" +
"that probably means we're no longer connected.");
se.printStackTrace();
System.exit(1);
}

ResultSet rs = null;
try {
rs = s.executeQuery("SELECT * FROM customers");
} catch (SQLException se) {
System.out.println("We got an exception while executing our query:" +
"that probably means our SQL is invalid");
se.printStackTrace();
System.exit(1);
}

int index = 0;


try {
while (rs.next()) {
System.out.println(rs.getString(1)+" "+rs.getString(2));
}
} catch (SQLException se) {
System.out.println("We got an exception while getting a result:this " +
"shouldn't happen: we've done something really bad.");
se.printStackTrace();
System.exit(1);
}
}
public static void main(String[] s)
{
new MySQL_Connection();
}
}

Options: ReplyQuote


Subject Written By Posted
problem with the connector panos karakontakis 01/20/2011 11:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.