anderson.pereira 18 de set. de 2010
Segue codigo da conexão, mais detalhes no arquivo, ele não passa pelo Class.forName(driver);
package Classes ;
import java.sql.Connection ;
import java.sql.DriverManager ;
import java.sql.SQLException ;
import javax.swing.JOptionPane ;
import javax.swing.JOptionPane ;
public class Conexao
{
public void inserir (){
JOptionPane . showMessageDialog ( null , "Entrou" );
String driver = "org.postgresql.Driver" ;
String user = "postgres" ;
String senha = "123456" ;
String url = "jdbc:postgresql://localhost:5432/Telecom" ;
try
{
JOptionPane . showMessageDialog ( null , "Antes do Try." );
JOptionPane . showMessageDialog ( null , driver );
Class . forName ( driver );
JOptionPane . showMessageDialog ( null , "Depois do Class." );
Connection con = null ;
JOptionPane . showMessageDialog ( null , "Depois do Try." );
con = ( Connection ) DriverManager . getConnection ( url , user , senha );
JOptionPane . showMessageDialog ( null , "Conexão realizada com sucesso." );
}
catch ( ClassNotFoundException ex )
{
JOptionPane . showMessageDialog ( null , ex . getMessage ());
JOptionPane . showMessageDialog ( null , "Problema no Class" );
//System.err.print(ex.getMessage());
}
catch ( SQLException e )
{
JOptionPane . showMessageDialog ( null , e . getMessage ());
}
}
}
anderson.pereira 18 de set. de 2010
segue erro
8 / 09 / 2010 17 : 29 : 24 org . apache . tomcat . util . digester . SetPropertiesRule begin
WARNING : [ SetPropertiesRule ] { Server / Service / Engine / Host / Context } Setting property 'source' to 'org.eclipse.jst.j2ee.server:ExercicioAjax' did not find a matching property .
18 / 09 / 2010 17 : 29 : 24 org . apache . tomcat . util . digester . SetPropertiesRule begin
WARNING : [ SetPropertiesRule ] { Server / Service / Engine / Host / Context } Setting property 'source' to 'org.eclipse.jst.j2ee.server:Trabalho' did not find a matching property .
18 / 09 / 2010 17 : 29 : 24 org . apache . tomcat . util . digester . SetPropertiesRule begin
WARNING : [ SetPropertiesRule ] { Server / Service / Engine / Host / Context } Setting property 'source' to 'org.eclipse.jst.j2ee.server:Telecom' did not find a matching property .
18 / 09 / 2010 17 : 29 : 24 org . apache . tomcat . util . digester . SetPropertiesRule begin
WARNING : [ SetPropertiesRule ] { Server / Service / Engine / Host / Context } Setting property 'source' to 'org.eclipse.jst.j2ee.server:Tcc' did not find a matching property .
18 / 09 / 2010 17 : 29 : 24 org . apache . tomcat . util . digester . SetPropertiesRule begin
WARNING : [ SetPropertiesRule ] { Server / Service / Engine / Host / Context } Setting property 'source' to 'org.eclipse.jst.j2ee.server:novotcc' did not find a matching property .
18 / 09 / 2010 17 : 29 : 24 org . apache . catalina . core . AprLifecycleListener init
INFO : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java . library . path : C : \ Arquivos de programas \ Java \ jre6 \ bin ;.; C : \ WINDOWS \ Sun \ Java \ bin ; C : \ WINDOWS \ system32 ; C : \ WINDOWS ; C : / Arquivos de programas / Java / jre6 / bin / client ; C : / Arquivos de programas / Java / jre6 / bin ; C : \ Arquivos de programas \ Nokia \ PC Connectivity Solution \ ; C : \ WINDOWS \ system32 ; C : \ WINDOWS ; C : \ WINDOWS \ System32 \ Wbem ; C : \ Arquivos de programas \ Microsoft SQL Server0 \ Tools \ BINN ;; C : \ Arquivos de programas \ Arquivos comuns \ Ahead \ Lib \
18 / 09 / 2010 17 : 29 : 24 org . apache . coyote . http11 . Http11Protocol init
INFO : Initializing Coyote HTTP / 1.1 on http - 8080
18 / 09 / 2010 17 : 29 : 24 org . apache . catalina . startup . Catalina load
INFO : Initialization processed in 500 ms
18 / 09 / 2010 17 : 29 : 24 org . apache . catalina . core . StandardService start
INFO : Starting service Catalina
18 / 09 / 2010 17 : 29 : 24 org . apache . catalina . core . StandardEngine start
INFO : Starting Servlet Engine : Apache Tomcat / 6.0.20
18 / 09 / 2010 17 : 29 : 25 org . apache . catalina . core . StandardContext resourcesStart
SEVERE : Error starting static Resources
java . lang . IllegalArgumentException : Document base C : \ Documents and Settings \ Anderson . APK \ workspace \ . metadata \ . plugins \ org . eclipse . wst . server . core \ tmp0 \ wtpwebapps \ Telecom does not exist or is not a readable directory
at org . apache . naming . resources . FileDirContext . setDocBase ( FileDirContext . java : 142 )
at org . apache . catalina . core . StandardContext . resourcesStart ( StandardContext . java : 4048 )
at org . apache . catalina . core . StandardContext . start ( StandardContext . java : 4217 )
at org . apache . catalina . core . ContainerBase . start ( ContainerBase . java : 1045 )
at org . apache . catalina . core . StandardHost . start ( StandardHost . java : 722 )
at org . apache . catalina . core . ContainerBase . start ( ContainerBase . java : 1045 )
at org . apache . catalina . core . StandardEngine . start ( StandardEngine . java : 443 )
at org . apache . catalina . core . StandardService . start ( StandardService . java : 516 )
at org . apache . catalina . core . StandardServer . start ( StandardServer . java : 710 )
at org . apache . catalina . startup . Catalina . start ( Catalina . java : 583 )
at sun . reflect . NativeMethodAccessorImpl . invoke0 ( Native Method )
at sun . reflect . NativeMethodAccessorImpl . invoke ( Unknown Source )
at sun . reflect . DelegatingMethodAccessorImpl . invoke ( Unknown Source )
at java . lang . reflect . Method . invoke ( Unknown Source )
at org . apache . catalina . startup . Bootstrap . start ( Bootstrap . java : 288 )
at org . apache . catalina . startup . Bootstrap . main ( Bootstrap . java : 413 )
18 / 09 / 2010 17 : 29 : 25 org . apache . catalina . core . StandardContext start
SEVERE : Error in resourceStart ()
18 / 09 / 2010 17 : 29 : 25 org . apache . catalina . core . StandardContext start
SEVERE : Error getConfigured
18 / 09 / 2010 17 : 29 : 25 org . apache . catalina . core . StandardContext start
SEVERE : Context [ /Telecom ] startup failed due to previous errors
18 / 09 / 2010 17 : 29 : 25 org . apache . catalina . core . StandardContext stop
INFO : Container org . apache . catalina . core . ContainerBase . [ Catalina ] . [ localhost ] . [ /Telecom ] has not been started
18 / 09 / 2010 17 : 29 : 25 org . apache . coyote . http11 . Http11Protocol start
INFO : Starting Coyote HTTP / 1.1 on http - 8080
18 / 09 / 2010 17 : 29 : 25 org . apache . jk . common . ChannelSocket init
INFO : JK : ajp13 listening on / 0.0.0.0 : 8009
18 / 09 / 2010 17 : 29 : 25 org . apache . jk . server . JkMain start
INFO : Jk running ID = 0 time = 0 / 15 config = null
18 / 09 / 2010 17 : 29 : 25 org . apache . catalina . startup . Catalina start
INFO : Server startup in 506 ms
java . lang . ClassNotFoundException : org . postgresql . Driver
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1387 )
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1233 )
at java . lang . ClassLoader . loadClassInternal ( Unknown Source )
at java . lang . Class . forName0 ( Native Method )
at java . lang . Class . forName ( Unknown Source )
at Classes . ConsultorDAO . inserir ( ConsultorDAO . java : 29 )
at Classes . Consultor . Inserir ( Consultor . java : 73 )
at org . apache . jsp . cadastro_jsp . _jspService ( cadastro_jsp . java : 80 )
at org . apache . jasper . runtime . HttpJspBase . service ( HttpJspBase . java : 70 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . jasper . servlet . JspServletWrapper . service ( JspServletWrapper . java : 374 )
at org . apache . jasper . servlet . JspServlet . serviceJspFile ( JspServlet . java : 342 )
at org . apache . jasper . servlet . JspServlet . service ( JspServlet . java : 267 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 233 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 191 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 128 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 102 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 293 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 849 )
at org . apache . coyote . http11 . Http11Protocol $ Http11ConnectionHandler . process ( Http11Protocol . java : 583 )
at org . apache . tomcat . util . net . JIoEndpoint $ Worker . run ( JIoEndpoint . java : 454 )
at java . lang . Thread . run ( Unknown Source )
anderson.pereira 18 de set. de 2010
Sim na verdade é java web e estou utilizando o Eclpse Galileu então configurei no Build Path.
e fiz com varios e o erro pelo que pesquesei é bem isso ele não encontra o .jar
anderson.pereira 18 de set. de 2010
zoren muito obrigado funcionou, so estava adicionando o jar estava na pasta java.
muito obrigado mesmo, valeu…
obrigado a todos.