• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Netbeans can not connect to my MySQL  RSS feed

 
Ranch Hand
Posts: 71
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm trying to connect to a mysql data base. I got the following :

I have been having trouble setting up MySQL to connect with Netbeans. I have included some snapshots.

The first snapshot is when it appears that the database are connected. Noticed the localhost:3306/mma?

and localhost3306/m ysql in the upper right corner seem to be connected. But when I try to list products it gives me an exception error :Stating that there is no suitable driver for jdbc:mysql://localhost: 3303/mma


In the new Connection Wizard, notices that the m ysql data base is selected. Should this be the mma database, can I just type the mma name in and test the connection?


I tested the m ysql (notices the name has a space "m ysql") is this right? The test concluded that the connection Succeeded.


When I pressed the finish button on snapshot 3 it gave me this message: that connection already exists.


I have installed, the "Murach's Java Programming" said that I should already have this type of connector: I could not find it. After installing this connector I have Jconnector 8.0.15 in a JARfile.

I'll attach the PNGs of the exception error, so that it explains my issue better.

Thanks for the help!

Bill
Net-beans_1.PNG
[Thumbnail for Net-beans_1.PNG]
Exception Error
Netbeans_2.PNG
[Thumbnail for Netbeans_2.PNG]
netbeans_3.PNG
[Thumbnail for netbeans_3.PNG]
 
Sheriff
Posts: 5930
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know why "m ysql" would be correct.  Try "mysql".  URLs can't have literal spaces.
 
Bill foster
Ranch Hand
Posts: 71
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help, actually a friend of mine said I should just select the file and use that as my MySQL library.

Here is a snap shot. Note I'm getting a SQL exception. This is okay and I'll just have to check my SQL statements in my java code.

At least now I can connect to the database.

I will be helping the students out with their assignments next semester and I want to brush up on Java before I do so.

Thanks Knute!

Bill
Exception_Error_3.PNG
[Thumbnail for Exception_Error_3.PNG]
Exception Error
 
Ranch Hand
Posts: 380
2
Fedora IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That exception isnt because it can't connect.  Is there a full stacktrace there?
 
Al Hobbs
Ranch Hand
Posts: 380
2
Fedora IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the exception is being caught so you can only see part of the error.  Did you create the table in the db or is it a script from the book?  If you didnt't write the code and you made the table then that might be where the problem is.
 
Knute Snortum
Sheriff
Posts: 5930
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a column index out of range.  You're trying to access column 5 and there's only 4 columns, probably in a line like rs.getString(5).
 
Bill foster
Ranch Hand
Posts: 71
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I got this to work, I actually have to add a column called note to the data base. I'll post this and my code for all to share.

I'm actually trying to tutor in core Java, and I just want to go through the text we are using so I know what I'm doing.

I think the students like myself have trouble with databases. The code actually works and I'm able to create a note column and this display it to the console.

The student get a kick out of it when I make mistakes, but after all that is how we learn, right?

What programming teaches the student is to create a solution not known yet. They all think I have the answers and they are shock to know I do not.

The key is to break the problem down in steps, the students must master the computer between thier ears first. Then we can code.

Actually, this is pretty cool stuff!

Thanks,

Bill
 
Bill foster
Ranch Hand
Posts: 71
2
Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code:

I had to add a note to the column of the data base then I had to code the following code the blow methods.
This first method I had to String note and set the note to the type Product p object. This is in my getProductFromRow(ResultSet rs) method.




Then I had to created a place holder for my note using the four  "?" in my sql string.
Then I had to set the string with ps.setString(4, product.getNote()), this is in my add method




I also had to do the same with the update method as well.



I will give you guys some output as well, this is attached.

Thanks for the help guys, this is a great place to get help.

Thanks again,

Bill


MySQL_Output.PNG
[Thumbnail for MySQL_Output.PNG]
 
Knute Snortum
Sheriff
Posts: 5930
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a cow for posting your solution back to the forum.
 
Bill foster
Ranch Hand
Posts: 71
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow my first Cow! Who says having a cow is a bad thing! LOL!!!

Thanks,

Bill
 
Sheriff
Posts: 24374
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, cows is good!
 
Bill foster
Ranch Hand
Posts: 71
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know the cows are good it's a award. I'm really happy to be one of the gang now.

Thanks everyone and thanks Knute for the cow.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!