hello all,
i am trying to connect a java application to a mysql database. But when i run the application, i get this error: com.mysql.jdbc.Driver. What am i doing wrong?
this is my code
Class.forName("com.mysql.jdbc.Driver").newInstance ();
con = DriverManager.getConnection("jdbc:mysql://localhost:8080//test","root", "password");
stat = con.createStatement();
korkor
8 5908
hello all,
i am trying to connect a java application to a mysql database. But when i run the application, i get this error: com.mysql.jdbc.Driver. What am i doing wrong?
this is my code
Class.forName("com.mysql.jdbc.Driver").newInstance ();
con = DriverManager.getConnection("jdbc:mysql://localhost:8080//test","root", "password");
stat = con.createStatement();
korkor
Did you add it to your classpath, or associate it as a library with the project?
Hi sicarie,
If i am using a remote web server located at http://www.companyname.com, how can i use his kind of drivers.
Did you add it to your classpath, or associate it as a library with the project?
is this the way to add to the class path?
Class c = Class.forNames("com.mysql.jdbc.Driver");
korkor
Hi sicarie,
If i am using a remote web server located at http://www.companyname.com, how can i use his kind of drivers.
ajaxrand-
It's considered bad form to "hijack" some else's thread (ask your question in their thread. Please start your own thread for this question.
is this the way to add to the class path?
Class c = Class.forNames("com.mysql.jdbc.Driver");
korkor
No, classpath is dependent on computer - are you on Windows or Linux?
[quote=sicarie]No, classpath is dependent on computer - are you on Windows or Linux?[/QUOTE
im on windows
korkor
what is the driver you are using in your machine to connect with MySQL ?
korkor-
From the Start Menu, go to Settings and click on 'Control Panel'. Then go to the System icon (in classic view, I'm not sure if this is in category view or not), and the 'Advanced' tab from there. In the Advanced tab, click on the Environmental Variables button. This will display your path (it's in the bottom box, you might have to scroll down for it). You only want to add to this (not delete anything that is not there. Highlight the Path and click the edit button, and then add the absolute location of your driver. Make sure this location is separated from the entries before and after it with a semi-colon and no spaces.
For instance, this is mine:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem
and I would change this to:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem;C:\Windows\drivers\jdbc\com.mysql.jdbc .Driver.jar;
An easier option (and one that's more portable), is to (depending on your IDE) add it as a library - in NetBeans, you just right-click on Library, add jar, and find the file.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: apchar |
last post by:
I am trying to use php as a kind of servlet to act as a middle man
between a java applet and mysql. I know java has jdbc but it's flakey
and painful. php access to mysql is much nicer. So I have:...
|
by: Mark |
last post by:
Using a Java program, I can connect to the test database in MySQL. The
test database is installed using a MySQL utility, and it can be accessed
by any user without supplying a password. The...
|
by: WilHob |
last post by:
Hello:
I can not make connection to MySQL from Java.
I set System Variable CLASSPATH to:
C:\MySQL\mysql-connector-java-5.0.5\mysql-connector-java-5.0.5-bin.jar
...
Then registered Driver:...
|
by: oll3i |
last post by:
package library.common;
import java.sql.ResultSet;
public interface LibraryInterface {
public ResultSet getBookByAuthor(String author);
public ResultSet getBookByName(String name);
|
by: nickyeng |
last post by:
imageValue=null
SEVERE:-->
com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Column 'Gout_msgtext' cannot be null
at...
|
by: Ananthu |
last post by:
Hi
I have done all the codings part for connecting mysql with java in eclipse environment.
Coding Part:
import java.sql.Connection;
import java.sql.DriverManager;
public class...
|
by: dmstn |
last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in...
|
by: swethak |
last post by:
hi,
when i run a java program for to store data and retrive using mysql datatabse i got the following errors.I think in that one of error is due to set the class path.I placed my...
|
by: asti1987 |
last post by:
I have a big problem, y need to print a jasper report, but it must to be with jsp.
this is my jsp
please help me
<%@ page...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |