• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connecting to a database

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah you're probably right, a test console application will be easier to establish a connection.
 
Claude Moore
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool,

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

Thanks again
 
Claude Moore
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome. Glad it helped!
reply
    Bookmark Topic Watch Topic
  • New Topic