Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to a database

 
Paul Ryan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

Been trying for the last couple of hours trying to connect to mysql database with no luck. I have the port number right but it is still not connecting. Heres the code:


This then brings up a user screen but when I click log in (no matter what I put in the text fields) I get this
ant -f C:\\Users\\Paul17\\Documents\\NetBeansProjects\\LibraryApplicationProject jfxsa-run
init:
Deleting: C:\Users\Paul17\Documents\NetBeansProjects\LibraryApplicationProject\build\built-jar.properties
deps-jar:
Updating property file: C:\Users\Paul17\Documents\NetBeansProjects\LibraryApplicationProject\build\built-jar.properties
Compiling 1 source file to C:\Users\Paul17\Documents\NetBeansProjects\LibraryApplicationProject\build\classes
compile:
Detected JavaFX Ant API version 1.3
Launching <fx:jar> task from C:\Program Files\Java\jdk1.8.0_25\jre\..\lib\ant-javafx.jar
Warning: From JDK7u25 the Codebase manifest attribute should be used to restrict JAR repurposing.
Please set manifest.custom.codebase property to override the current default non-secure value '*'.
Launching <fx:deploy> task from C:\Program Files\Java\jdk1.8.0_25\jre\..\lib\ant-javafx.jar
jfx-deployment-script:
jfx-deployment:
jar:
Copying 12 files to C:\Users\Paul17\Documents\NetBeansProjects\LibraryApplicationProject\dist\run1191448749
jfx-project-run:
Executing C:\Users\Paul17\Documents\NetBeansProjects\LibraryApplicationProject\dist\run1191448749\LibraryApplicationProject.jar using platform C:\Program Files\Java\jdk1.8.0_25\jre/bin/java
SELECT * FROM student WHERE USERID= '' AND PASSWORD= ''
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3307/student
Deleting directory C:\Users\Paul17\Documents\NetBeansProjects\LibraryApplicationProject\dist\run1191448749
jfxsa-run:
BUILD SUCCESSFUL (total time: 6 seconds)


I have added a screen shot of the mysql databases view in netbeans.

Any help would be greatly appreciated.

Thank you.



mysqlpicture.png
[Thumbnail for mysqlpicture.png]
 
Claude Moore
Ranch Hand
Posts: 829
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ad from errors you reported, no suitable driver for MySQL is found: probabily required jars are not round in your application classpath. Why don't you try with a simple console-based application before using java FX ?
 
Paul Ryan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah you're probably right, a test console application will be easier to establish a connection.
 
Claude Moore
Ranch Hand
Posts: 829
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you are just running some tests, but generally speaking is always better to clean separate data access logic from GUI frontend.So the extra work may be worth.
 
Paul Ryan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Switched over to eclipse and adding the jar to the build path and problem has been fixed. Thanks for the advice. Just one more question, when you say separate data access logic from GUI frontend do you mean put anything related to the database into a different package?
 
Claude Moore
Ranch Hand
Posts: 829
7
IBM DB2 Java Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More generally, in a different class respect to GUI classes.packages separation allows keeping things well logically organized, so LAD class and GUI ones may be part of the same package.
 
Paul Ryan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool,

Thanks a lot Claude, will definitely use the advice you gave me.

Thanks again
 
Claude Moore
Ranch Hand
Posts: 829
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome. Glad it helped!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic