Unable to get connector/J to work

NetBeans ANT, mariaDB-java-client,connector/J, mariaDB.

-Server version: 10.11.11-MariaDB MariaDB package
-mariadb-java-client-3.4.2.jar

  • Product Version: Apache NetBeans IDE 27
  • Tried with eclipse too, doesn’t work there either.

TERMINAL:
anmaliei@m-ipv6:~> sudo mysql -u root -p -h localhost
[sudo] password for root:
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3

MariaDB [(none)]> SHOW DATABASES;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| mytest |
| performance_schema |
| sys |
±-------------------+

CREATE TABLE mytest (id INT NOT NULL AUTO_INCREMENT, A VARCHAR(20), B VARCHAR(20), PRIMARY KEY (id) );

SHOW COLUMNS FROM mytest;
±------±------------±-----±----±--------±---------------+
| Field | Type | Null | Key | Default | Extra |
±------±------------±-----±----±--------±---------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| A | varchar(20) | YES | | NULL | |
| B | varchar(20) | YES | | NULL | |
±------±------------±-----±----±--------±---------------+

INSERT INTO mytest (A,B) VALUES (SEBA,211118 );

MariaDB [mytest]> select * from mytest;
±—±-----±-------+
| id | A | B |
±—±-----±-------+
| 1 | SEBA | 211118 |
±—±-----±-------+


NetBeans ANT :
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Mydbtestaa
{
Connection connection = null;
String url = “jdbc:mariadb://localhost:3306/mytest”;
String username = “root”;
String password = “password”;

public Mydbtestaa()
{
try{
connection = DriverManager.getConnection(url, username, password);
System.out.println(“Connection Successful.”);
} catch (SQLException e) { System.out.println(“Connection Failed.”+e); }
finally
{ if (connection != null) try { connection.close(); } catch (SQLException ignore) {} }
}/////////

I’ve tried copying connector/J into the java library, into the program’s class library.
There’s no CLASSPATH either.
Many suggestions on the web are old.
Does anyone KNOW how to get connector/J to work?

We’ve asked a couple of times to post output in pre-formatted text ( </> in de edit window ). This is unreadable.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.