2013-08-09 37 views
5

için uygun bir sürücü bulunamadı Burada bunun gönderilebilecek olası bir kopyası olabileceğini biliyorum. Tutulma bu projeyi oluşturdukPostgres: jdbc

java.sql.SQLException: No suitable driver found for jdbc:posgresql://localhost:5432/postgres 
    at java.sql.DriverManager.getConnection(Unknown Source) 
    at java.sql.DriverManager.getConnection(Unknown Source) 
    at ManageEmployee.main(ManageEmployee.java:60) 

ve dış kavanoz ekledi: that.Here için üzgünüm i aşağıdaki istisna olsun bu kodu çalışırken ben Veritabanı bağlantısı

try{ 
      Class.forName("org.postgresql.Driver");  
     } 

     catch(ClassNotFoundException e) 
     { 
      e.printStackTrace(); 
     } 

     try{ 
      String URL = "jdbc:posgresql://localhost:5432/postgres"; 
      String USER = "postgres"; 
      String PASS = "postgres"; 
      Connection conn = DriverManager.getConnection(URL, USER, PASS); 
      Statement st = conn.createStatement(); 
      ResultSet rs = st.executeQuery("Select * from employee"); 
      while(rs.next()){ 
       System.out.println(rs.getString(1)); 
      } 

     } 

     catch(SQLException es){ 
      es.printStackTrace(); 
     } 

için yazdığı kodudur için daha iyi olur eğer postgres İşte

.classpath dosyasıdır

<?xml version="1.0" encoding="UTF-8"?> 
<classpath> 
    <classpathentry kind="src" path="src"/> 
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> 
     <attributes> 
      <attribute name="owner.project.facets" value="java"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> 
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> 
    <classpathentry kind="lib" path="//10.202.6.95/kavitha_share/jars/postgresql-8.2-504.jdbc2ee.jar"/> 
    <classpathentry kind="output" path="build/classes"/> 
</classpath> 

Zaten kavanozları ekledim olası nedeni ne olabilir?

cevap

18

posgresql değerini postgresql olarak değiştirin.

jdbc:posgresql://localhost:5432/postgres 

olur:

jdbc:postgresql://localhost:5432/postgres 

karakteri unutmayın 't' pos t gresql

+1

Teşekkür hile yapan bir sürü yer. –

+15

Esnek takılabilir API'ların olumsuz tarafı - hiçbir zaman "oops, bir yazım hatası yaptınız" diyemezler –