CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 connection jdbc mysql : please help!

Print topic Send  topic

Author Message
mySQLnewbie
Posted: 05/18/2005, 1:51 AM

I'm trying to test my connection to the mysql driver, and i keep getting this message:

when i execute with the command line:
java Jdbc11 , i get this
Exception in thread "main" java.lang.NoClassDefFounfError: Jdbc11

and when i execute the same program with this command line :
java -cp .;\C:\mennen\downloads\connectorJ\mysql-connector-java-3.1.8a.jar Jdbc11 , i get:
ClassNotFoundException: com.mysql.jdbc.Driver

Jdbc11.java compiles ok.
I'm using
j2sdk1.4.2_08
mysql-connector-java-3.1.8a.tar
mysql-essential-4.1.11-win32
Wind XP


path = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Fichiers communs\Adaptec Shared\System;C:\Program Files\MySQL\MySQL Server 4.1\bin;%JAVA_HOME%\bin

where JAVA_HOME = "C:\j2sdk1.4.2_08"
and i also created a variable CLASSPATH = "C:\mennen\downloads\connectorJ\mysql-connector-java-3.1.8a.tar"

I also put the mysql-connector-java-3.1.8a.tar in the C:\j2sdk1.4.2_08\jre\lib\ext directory.

I've tried a lot of things i've read on forums, but it just doesn't wanna work
I also tried executing it with
java -cp .;\C:\mennen\downloads\connectorJ\mysql-connector-java-3.1.8a.jar Jdbc11
but it still won't work!

Here is Jdbc11.java
_____________________________________________________________________
import java.sql.*;

public class Jdbc11 {

public static void main(String args[]){
System.out.println(
"Mennen ELKALYOUBI testing..");
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/mysql";
Connection con =DriverManager.getConnection(url,"root", "mennen"); //mennen is the password i use when i log onto mysql
System.out.println("URL: " + url);
System.out.println("Connection: " + con);
con.close();
}

catch (java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}}
___________________________________________________________________

Please help!!
Jonathan Balinski
Posted: 06/13/2005, 9:00 PM

Have you imported your MySQL jdbc driver library into your project?

eserver221
Posted: 06/13/2005, 9:42 PM

Quote mySQLnewbie:
I'm trying to test my connection to the mysql driver, and i keep getting this message:

when i execute with the command line:
java Jdbc11 , i get this
Exception in thread "main" java.lang.NoClassDefFounfError: Jdbc11

and when i execute the same program with this command line :
java -cp .;\C:\mennen\downloads\connectorJ\mysql-connector-java-3.1.8a.jar Jdbc11 , i get:
ClassNotFoundException: com.mysql.jdbc.Driver

Jdbc11.java compiles ok.
I'm using
j2sdk1.4.2_08
mysql-connector-java-3.1.8a.tar
mysql-essential-4.1.11-win32
Wind XP


path = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Fichiers communs\Adaptec Shared\System;C:\Program Files\MySQL\MySQL Server 4.1\bin;%JAVA_HOME%\bin

where JAVA_HOME = "C:\j2sdk1.4.2_08"
and i also created a variable CLASSPATH = "C:\mennen\downloads\connectorJ\mysql-connector-java-3.1.8a.tar"

I also put the mysql-connector-java-3.1.8a.tar in the C:\j2sdk1.4.2_08\jre\lib\ext directory.

I've tried a lot of things i've read on forums, but it just doesn't wanna work
I also tried executing it with
java -cp .;\C:\mennen\downloads\connectorJ\mysql-connector-java-3.1.8a.jar Jdbc11
but it still won't work!

Here is Jdbc11.java
_____________________________________________________________________
import java.sql.*;

public class Jdbc11 {

public static void main(String args[]){
System.out.println(
"Mennen ELKALYOUBI testing..");
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/mysql";
Connection con =DriverManager.getConnection(url,"root", "mennen"); //mennen is the password i use when i log onto mysql
System.out.println("URL: " + url);
System.out.println("Connection: " + con);
con.close();
}

catch (java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}}
___________________________________________________________________

Please help!!


It should be c:\menne not \c:\mennen

java -cp .;\C:\mennen\downloads\connectorJ\mysql-connector-java-3.1.8a.jar Jdbc11
Jagannath
Posted: 07/20/2005, 11:47 PM

import javax.swing.*;
import java.sql.*;
import java.awt.event.*;
import java.awt.*;
import java.*;
import javax.sql.*;
import java.io.*;


/*<applet code=vish height=500 width=500></applet>*/

public class vish extends JApplet implements ActionListener
{
JPanel p;
JLabel l1,l2,l3;
JTextField t1,t2,t3,t4;
JButton b1,b2;
public void init()
{
p = new JPanel();
l1 = new JLabel("Account id");
l1 = new JLabel("Transaction Type");
l1 = new JLabel("Amount");
t1 = new JTextField(15);
t2 = new JTextField(15);
t3 = new JTextField(15);
t4 = new JTextField(15);
b1 = new JButton("Display");
b2 = new JButton("Clear");


p.setLayout(null);
getContentPane().add(p);
l1.setBounds(10,10,120,25);
t1.setBounds(140,10,120,25);

l2.setBounds(10,45,120,25);
t2.setBounds(140,45,120,25);

l3.setBounds(10,70,120,25);
t3.setBounds(140,70,120,25);

t4.setBounds(10,100,120,25);

b1.setBounds(10,130,120,25);
b2.setBounds(140,130,120,25);

p.add(l1);
p.add(l1);
p.add(l1);
p.add(t1);
p.add(t2);
p.add(t3);
p.add(t4);
p.add(b1);
p.add(b2);

b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed (ActionEvent et)
{
String s= et.getActionCommand();
String cc= t4.getText();
{
if(s.equals("Display"))
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:ms

access:Driver={Microsoft Access Driver (pan*.mdb}));
Statement st = c.createStatement();
ResultSet r = st.executeQuery("select * from sa where acid =

'"+cc+"'");

if(r.next ()==false);
{
getAppletContext().showStatus("Record Not Found");
}
else
{
t1.setText(r.getString(1));
t2.setText(r.getString(2));
t3.setText(String.valueOf(r.getInt(4)));
}
}

catch(Exception e)
{
System.out.println(e);
}
}
else
{
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
}
}
}
}






I have Ms Access but i dont know how get Connection with Ms Access
Please send on my email

Thank You
shyam
Posted: 08/19/2005, 10:13 PM

kindly give me the sample code for mysql with java connection under linux platform

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.