Hi,
I've working with postgreSQL and JDBC. I've made some proves and all has gone ok. But now, I've to do in other machine.
There is Postgresql 7.3.2, with ant. I've the in CLASSPATH the jar file.
But when I tried to run the code there is thrown a exception when it try to getConnection:
Something unusual has occured to cause the driver to fail. Please report this
exception: Exception: java.lang IllegalArgumentException: sun.io.CharToByteUTF-8 ...."
The thing it's that the same code works in other matchine, and I'm not able to find the error.
I've been looking for it, but I haven't got any result.
Does anybody know where is my fault?
Thanks a lot,
yours
Cris..
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/
import java.sql.*;
class CtrlDatMartes
{
private static Connection conn;
public boolean RealizarConexion() throws Exception
{
boolean conectat = false;
if(ActivacioDrivers())
{
try
{
conn = DriverManager.getConnection("jdbc:postgresql://localhost/cris","postgres","XXXX"); // <- Here my fault must be, but it should work, shouldn't it????
conectat = true;
}
catch(SQLException sqlex)
{
System.out.println("Cach");
System.out.println(sqlex.getErrorCode());
throw (new Exception(String.valueOf(sqlex.getMessage())));
}
}
return conectat;
}
private boolean ActivacioDrivers() throws Exception
{
boolean activat = false;
try
{
Class.forName("org.postgresql.Driver");
activat = true;
}
catch(ClassNotFoundException ex)
{
throw (new Exception("[???:] Error en l'activació dels DRIVERS."));
}
return activat;
}
}
/*------------------------------------------------------------------------------------------------------------------------------------------------------*/