LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Wrote java program and can't connect to sql database (https://www.linuxquestions.org/questions/programming-9/wrote-java-program-and-cant-connect-to-sql-database-655291/)

mokoena 07-12-2008 07:33 AM

Wrote java program and can't connect to sql database
 
HI GUYS!

Um new to linux and i wrote a java program trying to connect to sql
database,my problem is that i can't find the location for my database.
I created a database with the name "New" and tried to use this directory "jbdc:mysql://localhost/New" but connection can't be established.
Can someone help me with the directory for created databases?

rjlee 07-12-2008 10:01 AM

Code:

jbdc:mysql://localhost/New
This is a JDBC connection string, not a directory.

The string looks right, assuming that you are using MySQL, and "New" is the name of the database that you are connecting to.

First make sure that the MySQL server is running on the local machine, and that you have created the "New" database; you might try connecting with the mysql command-line. It might well be that MySQL has downcased the name to "new", for example.

This will show you the currently defined databases, as MySQL sees them:
Code:

echo "show databases;" | mysql -u username -p
You don't have to use MySQL as a database back-end; managed databases are very powerful but do involve setting quite a lot up. You might try using a JDBC provider that doesn't require a full managed database service to be running, such as hypersonic (http://www.hsqldb.org/), just to verify that there isn't anything wrong with your Java code, before going back and fixing the database connection.


All times are GMT -5. The time now is 07:18 AM.