Ciao a tutti!!Io ho lo stesso problema, cioè a tempo di run time il messaggio che esce fuori è questo:
codice:
Exception in thread "main" PersistenceException: No suitable driver found for dbURI,userName,password 	at DataSource.getConnection(DataSource.java:25) 	at Main.main(Main.java:22)
Vi faccio vedere le mie semplici classi che ho creato:
Cliente:
codice:
  public class Cliente  { 	private int id_cl; 	private int codice_cliente; 	private String nome; 	private String cognome; 	private String indirizzo; 	 	 	 	  	public int getId_cl() { 		return id_cl; 	}  	public void setId_cl(int c)  { 		this.id_cl=c; 	}  	public int getCodice_cliente() { 		return codice_cliente; 	}  	public void setCodice_cliente(int codiceCliente) { 		codice_cliente = codiceCliente; 	}  	public String getNome() { 		return nome; 	}  	public void setNome(String nome) { 		this.nome = nome; 	}  	public String getCognome() { 		return cognome; 	}  	public void setCognome(String cognome) { 		this.cognome = cognome; 	}  	public String getIndirizzo() { 		return indirizzo; 	}  	public void setIndirizzo(String indirizzo) { 		this.indirizzo = indirizzo; 	}   	 }
PersistenceException
codice:
  public class PersistenceException extends Exception {  	/** 	 *  	 */ 	private static final long serialVersionUID = -3835068319580102263L;  	public PersistenceException(String msg){ 		super(msg); 	}  	 }
Classe DataSource
codice:
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;   public class DataSource  { 	 	public String dbURI = "jdbc:postgresql://localhost/Prova:5432"; 	public String userName = "postgres"; 	public String password = "kaos83"; 	 	public Connection getConnection() throws PersistenceException 	{ 		Connection connection; 		try 		{ 			 			Class.forName("org.postgresql.Driver"); 			connection = DriverManager.getConnection("dbURI,userName,password"); 			 		} 		catch (ClassNotFoundException e) { 			throw new PersistenceException(e.getMessage()); 		} catch(SQLException e) { 			throw new PersistenceException(e.getMessage()); 		} 		return connection; 	} }
un piccolo main per verificare che il tutto funzioni:
codice:
import java.sql.*;   public class Main  { public static void main (String [] args) throws PersistenceException  { 	Connection connection = null; 	PreparedStatement statement = null; 	DataSource ds = new DataSource(); 	Cliente c = new Cliente(); 	c.setCodice_cliente(1); 	c.setCognome("rossi"); 	c.setId_cl(2); 	c.setIndirizzo("ciao"); 	c.setNome("marko"); 	 	String query ="INSERT into clienti(codice_cliente,nome,cognome,indirizzo,id_cl) VALUES (?,?,?,?,?)"; 	try  	{ 		connection=ds.getConnection(); 		statement = connection.prepareStatement(query); 		statement.setInt(1, c.getCodice_cliente()); 		statement.setString(2, c.getNome()); 		statement.setString(3, c.getCognome()); 		statement.setString(4,c.getIndirizzo()); 		statement.setInt(5,c.getId_cl()); 		statement.executeUpdate(); 	} 	catch (SQLException e) 	{ 		throw new PersistenceException(e.getMessage()); 	} 	finally 	{ 		try 		{ 			if(statement!=null) 				statement.close(); 			if(connection!=null) 				connection.close(); 		} 		catch (SQLException e) 		{ 			throw new PersistenceException (e.getMessage()); 		} 	 	} } }
Ho controllato che username,password e uri siano corretti ed ho anche aperto il dataSourceExploer in Eclipse per vedere se il ping con il db andava a buon fine ed è tutto ok.
Ho scaricato inoltre il Driver di postgres jdbc4 dato che la mia jre è la 1.6.Il driver stà nel mio classpath c:\Utenti\DocumentAndSetting\Marco.Ovviamente ho anche creato la mia tabella clienti in postgres.Cosa posso fare?Grazie