JDBC/mysql error...




Hi everyone,

I got an error, when i tried to connect mysql with java. Any
suggestions ?

Thank you.


Bug Report
==========

OS : RedHat Fedora Core 6

JSDK version : javac 1.5.0_12 [Linux version]

MySQL version : mysql Ver 14.12 Distrib 5.0.22, for redhat-linux-gnu
(i686) using readline 5.0

MySQL/JConnector version : mysql-connector-java-5.0.7

Query used for creating the db
==============================

drop database movies;
create database movies;
use movies;
create table movie (
id int not null auto_increment,
title varchar(50),
year int,
price decimal(8,2),
primary key(id)
);

insert into movie (title,year,price)
values("FirstMovie",1901,14.95);
insert into movie (title,year,price)
values("SecondMovie",1902,15.33);

Java code
=========

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Test
{
public static void main(String[] args)
{
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("Registering Driver...[OK]");
}

catch(Exception ex)
{
System.out.println("Cannot register the driver");
}


try
{
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost/
movies?"+"user=thushanthan&password=phpmysql");
System.out.println("Establishing Connection...[OK]");
}

catch(SQLException ex)
{
System.out.println("SQLException: "+ex.getMessage());
System.out.println("SQLState: "+ex.getSQLState());
System.out.println("VendorError: "+ex.getErrorCode());
}
}
}


Error
=====

Registering Driver...[OK]
SQLException: Error during query: Unexpected Exception:
java.io.CharConversionException message given: null

Nested Stack Trace:


** BEGIN NESTED EXCEPTION **

java.io.CharConversionException

STACKTRACE:

java.io.CharConversionException
at gnu.gcj.convert.Input_iconv.read(libgcj.so.7rh)
at java.lang.String.init(libgcj.so.7rh)
at java.lang.String.<init>(libgcj.so.7rh)
at
com.mysql.jdbc.SingleByteCharsetConverter.<init>(SingleByteCharsetConverter.java:
153)
at
com.mysql.jdbc.SingleByteCharsetConverter.initCharset(SingleByteCharsetConverter.java:
108)
at
com.mysql.jdbc.SingleByteCharsetConverter.getInstance(SingleByteCharsetConverter.java:
86)
at com.mysql.jdbc.Connection.getCharsetConverter(Connection.java:
3478)
at com.mysql.jdbc.StringUtils.getBytes(StringUtils.java:615)
at com.mysql.jdbc.Buffer.writeStringNoNull(Buffer.java:655)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1686)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3250)
at
com.mysql.jdbc.Connection.configureClientCharacterSet(Connection.java:
2514)
at
com.mysql.jdbc.Connection.initializePropsFromServer(Connection.java:
4112)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2762)
at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:
285)
at java.sql.DriverManager.getConnection(libgcj.so.7rh)
at java.sql.DriverManager.getConnection(libgcj.so.7rh)
at Test.main(Test.java:25)


** END NESTED EXCEPTION **


SQLState: S1000
VendorError: 0

.



Relevant Pages

  • Re: Optimising MySQL queries against huge databases?
    ... I agree with Michael about the explain, but i did not try that, so the ... there are probably MANY movies that have an image and a director. ... Unless MySQL has a special optimization for ORDER BY RAND() LIMIT .. ...
    (comp.lang.php)
  • Re: Java and MySql program example ?
    ... > I am trying to learn Java and need an example program with MySql ... > MySql database. ... Database connection established ...
    (comp.lang.java.programmer)
  • Re: mysql vs sqlite vs hsql
    ... My question isabout benchmarks and multiple inserts & ... > I current have a mysql database of approx. ... lemme dispell the very common misconception that java is slow. ...
    (comp.lang.python)
  • Re: [SLE] schemaSpy
    ... >>> java ... >> page and modified it for MySQL and my local setup, ... >> any queries on behalf of schemaSpy (ascertained by logging in to ...
    (SuSE)
  • Re: asp, php or java, .net or what?
    ... I only do php and mysql, but recently someone told me that these are ... Java has greater support for other ... Many hosts offer the option of LAMP+IIS ...
    (alt.html)