Hi Instructor,
Currently using XAMMP for my OSX from https://www.apachefriends.org/index.html
And lately I am using 7.4.10 also note Since XAMPP 5.5.30 and 5.6.14, XAMPP ships MariaDB instead of MySQL. The commands and tools are the same for both. So I am using MariaDB. In the attached screen shot I am using exact simila code as per your lecture in Selenium Database Testing's "AVA DATABASE CONNECTIVITY - JDBC" where you show us to connect to DB and fire a queri.
I am using mariadb-java-clien-2.6.1.jar with Java SE 8 [1.8.0_264] I have the mariaDB working on the browser's localhost:8080 etc and that is working
But when uing the JAVA code as you se in screen shot I get this error:
java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=localhost)(port=8080)(type=master) : Could not connect to localhost:8080 : unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
Which I am not sure. I also saw some other videos where they do similar thing to connect to database but I can't figure out what is wrong so please can you look at issue and suggest some fix.
Thank you,
Monal
Error:
java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=localhost)(port=8080)(type=master) : Could not connect to localhost:8080 : unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:192)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1372)
at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:635)
at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:150)
at org.mariadb.jdbc.Driver.connect(Driver.java:89)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at DBConnection.main(DBConnection.java:25)
Caused by: java.sql.SQLNonTransientConnectionException: Could not connect to localhost:8080 : unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:183)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createConnection(AbstractConnectProtocol.java:566)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1367)
... 6 more
Caused by: java.io.EOFException: unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
at org.mariadb.jdbc.internal.io.input.StandardPacketInputStream.getPacketArray(StandardPacketInputStream.java:249)
at org.mariadb.jdbc.internal.io.input.StandardPacketInputStream.getPacket(StandardPacketInputStream.java:218)
at org.mariadb.jdbc.internal.com.read.ReadInitialHandShakePacket.<init>(ReadInitialHandShakePacket.java:89)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createConnection(AbstractConnectProtocol.java:518)
... 7 more
Instructor
Ashish Thakur Replied on 30/09/2020
Is mariadb running?
I think it runs on port 3306
and you are using 8080 in code