Adam Burda

Ranch Hand
+ Follow
since Jul 19, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Adam Burda

so I made a ClassPath C:\Program Files (x86)\Java\jre7\lib\mysql-connector-java-5.1.34-bin.jar
then re compiled my app then ran it now I get an error could not find or load main class
There is no ClassPath in windows 7 only path.
Hi all,

I do not understand what I am doing wrong. I'm trying to set the path to the J connector.
Then run a java app to check connection. I get JDBC driver not found
I have the mysql-connector-java-5.1.34-bin.jar placed in C:\Program Files (x86)\Java\jre7\lib folder.
So the path would be C:\Program Files (x86)\Java\jre7\lib\mysql-connector-java-5.1.34-bin.jar
and then in Windows 7 path variables edit, it looks like
......;C:\Program Files (x86)\Java\jdk1.7.0_71\bin;C:\Program Files (x86)\Java\jre7\lib\mysql-connector-java-5.1.34-bin.jar

java version = 7
jdk1.7.0_71
MySQL version = 5.6
MySQL Workbench 6.2 CE
Ok im a little lost here? What do you mean -cp? As for the Manifest.txt file, I opened note pad inside that I wrote

Main-Class: Contact

Saved that as MyManifest.txt to the folder where the app files are.

Contatc is the main of the app.
the files are
Contact.java
ContactFrame.java
ContactP.java

The class files are.
Contact.class
ContactFrame.class
ContactP$1.class
ContactP$ButtonListener.class
ContactP.class

Then in CMD I wrote

jar cfm JarFileName.jar MyManifest.txt Contact.class ContactFrame.class ContactP$1.class ContactP$Buttonlistener.class ContactP.class
11 years ago
I am not sure what you are asking.

added the drivers .jar file to the class path variable. c:\mysql\mysql-connector-java-5.0.4-bin.jar
11 years ago
I downloaded a driver from mysql.com/products/connector, unziped it, added the drivers .jar file to the class path variable. c:\mysql\mysql-connector-java-5.0.4-bin.jar
in the class file i have

import java.sql*.;

and in the ButtonLinstener method i have

System.out.println("Inserting values in Mysql database table!");
Connection con = null;
String url = "jdbc:mysql://localhost/ContactList";
String user = "root";
String pw = "marty95";
String driver = "com.mysql.jdbc.Driver";
11 years ago
Ok,
Sorry that the code was so long here is the SQL part of the code. It is with in the ButtonListener method of the class.



As for making the .jar file what I did was,
1. Made a MyManifest.txt file and in that i wrote Main-Class: Contact then pressed enter twice saved the file named MyManifest. Contact is the main class of my app.
2. in CMD i wrote jar cfm JarFileName.jar MyManifest.txt Contact.class ContactFrame.class ContactP$1.class ContactP$ButtonListener.class ContactP.class

The jar file works, the app runs. But as for sending data to the SQL table that does not work.
It only sends data to the SQL table if I run the app in CMD.
11 years ago
I need some help and hope I am in the right place.

I made a Java database app in a GUI. The app runs fine with no errors, and does what I want it to do. When I make the app into a .jar the app starts up but does not input data into the MySQL table. Here is the code.
I even took out the System.out.println(); and tryed again with making the .jar file still does not work.

11 years ago
If you look at code line 170, you will see where it has to do with JDBC. It will not load, keep getting errors.
11 years ago
Ok sorry about the code. I was only showing the inner class here is the whole code.

11 years ago
If you look at the code the static errors are there
line 42
line 44
line 46

So how do i go about fixing it. I tryed to make it as its own class file, and instantiate the class in a nother class.
But i keep getting throw or catch errors. When the class already has the throw and catch exception.
11 years ago
Hi all hope you can help.
I am getting three errors for a inner class. Here is the class.


.\ContactP.java:162: error: Illegal static declaration in inner class ContactP.ContactSql
static Connection conn;

modifier 'static' is only allowed in constant variable declarations
.\ContactP.java:164: error: Illegal static declaration in inner class ContactP.ContactSql
static Statement st;

modifier 'static' is only allowed in constant variable declarations
.\ContactP.java:166: error: Illegal static declaration in inner class ContactP.ContactSql
static {

modifier 'static' is only allowed in constant variable declarations
11 years ago
Thank you. I feel like DUH....
11 years ago
Need help. This should be simple, but i can not seem to get it.
I want to take a double like 0.01 and then times it by 2 for each output.
like this....
0.01
0.02
0.04
0.08
0.16
Do i use a loop of if, else?

Thank you.
11 years ago
Thank you. It works now.
11 years ago