Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Derby database problems

KrazyKatzKrazyKatz London, UKMember Posts: 1
edited June 2015 in Java Beginners

Hi there guys, thanks for reading!!

Im trying to learn how to create derby databases and have completed a tutorial program fine, but have now hit a brick wall on a program of my own and was hoping for a little advice. I think its only a minor error but I really cant spot it!

The Output im getting is:

Available drivers:

Table is created, but no content yet
DB contents:
Problem:java.sql.SQLNonTransientConnectionException: Connection authentication failure occurred. Reason: userid or password invalid.
Exception in thread "main" java.lang.NullPointerException
at rest.DataBaseCreator.showData(
at rest.Main.main(
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

I originally thought that there was something wrong with my username/pass but that is all fine, and someone on another forum suggested the error may come from somewhere else at the beginning of my code, before the getConnection:

package rest;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Enumeration;
public class DataBaseCreator
Connection connection;
Statement statement;

public DataBaseCreator()
catch (ClassNotFoundException cnfe)
System.err.println("Derby driver not found.");
System.out.println("Available drivers:");
Enumeration drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements())

     connection = DriverManager.getConnection

     statement = connection.createStatement();

And the I have is:

package rest;
public class Main {
public static void main(String[] args) {
DataBaseCreator table = new DataBaseCreator();
System.out.println("Table is created, but no content yet");
System.out.println("Table now populated with data");

In my DatabaseCreator, it the goes on to create the table, and the set and print the results, but im sure that part is fine, im pretty sure its somewhere around the drivers that im having issues??

Any advice would be gratefully received, as this is driving me crazy now!


Sign In or Register to comment.