| | |
No suitable driver found for jdbc:mysql://.... on jsf page
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2007
Posts: 23
Reputation:
Solved Threads: 0
This is the error what i get when i try to run my project:
I use netbeans 6.1, glassfisf v2 and mysql v5.
I have 2 seperate project - one is java and the other is web app. Java is linked via libraries to the main project. The java one contains all the class files. also i have jta, jsf, jtl, webui, toplink, mysql and the java project libraries attached to the main project
Here is the Propertyt.java
PropertyController.java
SessionBean1
I marked bold the lines where glassfish error is directing
JSF page code:
So can you please tell me why on earth i get this error and what i should do to fix it?
Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/varad1
Error Code: 0
at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:305)
at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:102)
at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource
(DatasourceLogin.java:184)
at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource
(DatabaseSessionImpl.java:582)
at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login
(EntityManagerFactoryProvider.java:280)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy
(EntityManagerSetupImpl.java:229)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.
getServerSession(EntityManagerFactoryImpl.java:93)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.
createEntityManagerImpl(EntityManagerFactoryImpl.java:126)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.
createEntityManagerImpl(EntityManagerFactoryImpl.java:120)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.
createEntityManager(EntityManagerFactoryImpl.java:91)
at com.samples.model.controller.PropertyController.getEntityManager
(PropertyController.java:23)
at com.samples.model.controller.PropertyController.getProperty(PropertyController.java:27)
at com.samples.web.SessionBean1.updateProperty(SessionBean1.java:136)
at com.samples.web.SessionBean1.init(SessionBean1.java:71)
at com.sun.rave.web.ui.appbase.servlet.LifecycleListener.attributeAdded
(LifecycleListener.java:327)
at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1706)
at org.apache.catalina.session.StandardSessionFacade.setAttribute
(StandardSessionFacade.java:163)
at com.sun.faces.context.SessionMap.put(ExternalContextImpl.java:972)
at com.sun.faces.application.ApplicationAssociate.createAndMaybe
StoreManagedBeans
(ApplicationAssociate.java:540)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:86)
at com.sun.el.parser.AstValue.getValue(AstValue.java:127)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:206)
at com.sun.webui.jsf.component.TableRowGroupBase.getSourceData(TableRowGroupBase.java:2758)
at com.sun.webui.jsf.component.TableRowGroupBase.getTableRowDataProvider
(TableRowGroupBase.java:582)
at com.sun.webui.jsf.component.TableRowGroupBase.getRowKey
(TableRowGroupBase.java:505)
at com.sun.webui.jsf.component.TableRowGroupBase.getClientId
(TableRowGroupBase.java:1353)
at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(
UIComponentClassicTagBase.java:1137)
at org.apache.jsp.Page1_jsp._jspx_meth_webuijsf_tableRowGroup_0(Page1_jsp.java from :411)
at org.apache.jsp.Page1_jsp._jspx_meth_webuijsf_table_0(Page1_jsp.java from :378)
at org.apache.jsp.Page1_jsp._jspx_meth_webuijsf_form_0(Page1_jsp.java from :336)
at org.apache.jsp.Page1_jsp._jspx_meth_webuijsf_body_0(Page1_jsp.java from :298)
at org.apache.jsp.Page1_jsp._jspx_meth_webuijsf_html_0(Page1_jsp.java from :198)
at org.apache.jsp.Page1_jsp._jspx_meth_webuijsf_page_0(Page1_jsp.java from :158)
at org.apache.jsp.Page1_jsp._jspx_meth_f_view_0(Page1_jsp.java from :120)
at org.apache.jsp.Page1_jsp._jspService(Page1_jsp.java from :86)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService
(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:317)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.processRequest
(ApplicationDispatcher.java:542)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:366)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:408)
at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView
(ViewHandlerImpl.java:442)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:
320)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
at com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.render
(PartialTraversalLifecycle.java:106)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at org.apache.catalina.core.ApplicationFilterChain.servletService
(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:317)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.
java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.
java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.
java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter
DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(Default
ProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(Default
ProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask
(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.
java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.
java:214)
at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnification
Pipeline.java:380)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.
java:106)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:
3306/varad1
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:100)
... 97 moreI have 2 seperate project - one is java and the other is web app. Java is linked via libraries to the main project. The java one contains all the class files. also i have jta, jsf, jtl, webui, toplink, mysql and the java project libraries attached to the main project
Here is the Propertyt.java
JSP Syntax (Toggle Plain Text)
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.samples.model; import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; /** * * @author kohuke */ @Entity @Table(name = "property") @NamedQueries({@NamedQuery(name = "Property.findByPropertyID", query = "SELECT p FROM Property p WHERE p.propertyID = :propertyID"), @NamedQuery(name = "Property.findByPropertyName", query = "SELECT p FROM Property p WHERE p.propertyName = :propertyName"), @NamedQuery(name = "Property.findByCreated", query = "SELECT p FROM Property p WHERE p.created = :created"), @NamedQuery(name = "Property.findByUpdated", query = "SELECT p FROM Property p WHERE p.updated = :updated")}) public class Property implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "property_ID", nullable = false) private Integer propertyID; @Column(name = "property_name", nullable = false) private String propertyName; @Column(name = "created", nullable = false) @Temporal(TemporalType.TIMESTAMP) private Date created; @Column(name = "updated") @Temporal(TemporalType.DATE) private Date updated; @JoinColumn(name = "property_type_ID", referencedColumnName = "property_type_ID") @ManyToOne private PropertyType propertytypeID; @JoinColumn(name = "created_by", referencedColumnName = "employee_ID") @ManyToOne private Employee createdBy; @JoinColumn(name = "updated_by", referencedColumnName = "employee_ID") @ManyToOne private Employee updatedBy; public Property() { } public Property(Integer propertyID) { this.propertyID = propertyID; } public Property(Integer propertyID, String propertyName, Date created) { this.propertyID = propertyID; this.propertyName = propertyName; this.created = created; } public Integer getPropertyID() { return propertyID; } public void setPropertyID(Integer propertyID) { this.propertyID = propertyID; } public String getPropertyName() { return propertyName; } public void setPropertyName(String propertyName) { this.propertyName = propertyName; } public Date getCreated() { return created; } public void setCreated(Date created) { this.created = created; } public Date getUpdated() { return updated; } public void setUpdated(Date updated) { this.updated = updated; } public PropertyType getPropertytypeID() { return propertytypeID; } public void setPropertytypeID(PropertyType propertytypeID) { this.propertytypeID = propertytypeID; } public Employee getCreatedBy() { return createdBy; } public void setCreatedBy(Employee createdBy) { this.createdBy = createdBy; } public Employee getUpdatedBy() { return updatedBy; } public void setUpdatedBy(Employee updatedBy) { this.updatedBy = updatedBy; } @Override public int hashCode() { int hash = 0; hash += (propertyID != null ? propertyID.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Property)) { return false; } Property other = (Property) object; if ((this.propertyID == null && other.propertyID != null) || (this.propertyID != null && !this.propertyID.equals(other.propertyID))) { return false; } return true; } @Override public String toString() { return propertyName; } }
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.samples.model.controller;
import com.samples.model.Property;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
/**
*
* @author kohuke
*/
public class PropertyController {
private EntityManagerFactory emf;
private EntityManager getEntityManager() {
if(emf == null){
emf = Persistence.createEntityManagerFactory("VaradModelAppPU");
}
return emf.createEntityManager();
}
public Property[] getProperty() {
EntityManager em = getEntityManager();
try{
javax.persistence.Query q = em.createQuery("select property_ID, property_name," +
"created,updated,created_by,updated_by from property");
return (Property[]) q.getResultList().toArray(new Property[0]);
} finally {
em.close();
}
}
}/*
package com.samples.web;
import com.samples.model.Employee;
import com.samples.model.Property;
import com.samples.model.PropertyClass;
import com.samples.model.PropertyType;
import com.samples.model.controller.EmployeeController;
import com.samples.model.controller.PropertyClassController;
import com.samples.model.controller.PropertyController;
import com.samples.model.controller.PropertyTypeController;
import com.sun.rave.web.ui.appbase.AbstractSessionBean;
import javax.faces.FacesException;
public class SessionBean1 extends AbstractSessionBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
private void _init() throws Exception {
}
// </editor-fold>
public SessionBean1() {
}
@Override
public void init() {
// Perform initializations inherited from our superclass
super.init();
try {
_init();
} catch (Exception e) {
log("SessionBean1 Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
updateProperty();
updatePropertyType();
updatePropertyClass();
updateEmployee();
try {
_init();
} catch (Exception e) {
log("SessionBean1 Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
private Employee[] employee;
public Employee[] getEmployee() {
return employee;
}
public void setEmployee(Employee[] employee) {
this.employee = employee;
}
private Property[] property;
public Property[] getProperty() {
return property;
}
public void setProperty(Property[] property) {
this.property = property;
}
private PropertyType[] propertyType;
public PropertyType[] getPropertyType() {
return propertyType;
}
public void setPropertyType(PropertyType[] propertyType) {
this.propertyType = propertyType;
}
private PropertyClass[] propertyClass;
public PropertyClass[] getPropertyClass() {
return propertyClass;
}
public void setPropertyClass(PropertyClass[] propertyClass) {
this.propertyClass = propertyClass;
}
public void updateProperty(){
PropertyController propertyController = new PropertyController();
property = propertyController.getProperty();
}
public void updatePropertyType(){
PropertyTypeController propertyTypeController = new PropertyTypeController();
propertyType = propertyTypeController.getPropertyType();
}
public void updatePropertyClass(){
PropertyClassController propertyClassController = new PropertyClassController();
propertyClass = propertyClassController.getPropertyClass();
}
public void updateEmployee(){
EmployeeController employeeController = new EmployeeController();
employee = employeeController.getEmployee();
}
@Override
public void passivate() {
}
@Override
public void activate() {
}
@Override
public void destroy() {
}
protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1) getBean("ApplicationBean1");
}
}JSF page code:
JSP Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="UTF-8"?> <!-- Document : Page1 Created on : 1.09.2008, 11:48:29 Author : kohuke --> <jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf"> <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/> <f:view> <webuijsf:page id="page1"> <webuijsf:html id="html1"> <webuijsf:head id="head1"> <webuijsf:link id="link1" url="/resources/stylesheet.css"/> </webuijsf:head> <webuijsf:body id="body1" style="-rave-layout: grid"> <webuijsf:form id="form1"> <webuijsf:table augmentTitle="false" id="table1" style="position: absolute; left: 96px; top: 144px" title="Table" width="0"> <webuijsf:tableRowGroup id="tableRowGroup1" rows="5" sourceData="#{SessionBean1.property}" sourceVar="currentRow"> <webuijsf:tableColumn headerText="propertyID" id="tableColumn1" sort="propertyID"> <webuijsf:staticText id="staticText1" text="#{currentRow.value['propertyID']}"/> </webuijsf:tableColumn> <webuijsf:tableColumn headerText="propertyName" id="tableColumn2" sort="propertyName"> <webuijsf:staticText id="staticText2" text="#{currentRow.value['propertyName']}"/> </webuijsf:tableColumn> <webuijsf:tableColumn headerText="propertytypeID" id="tableColumn3" sort="propertytypeID"> <webuijsf:staticText id="staticText3" text="#{currentRow.value['propertytypeID']}"/> </webuijsf:tableColumn> </webuijsf:tableRowGroup> </webuijsf:table> </webuijsf:form> </webuijsf:body> </webuijsf:html> </webuijsf:page> </f:view> </jsp:root>
Last edited by kohuke; Sep 1st, 2008 at 6:39 am.
says it all. Toplink can't find the jdbc driver for the database you're telling it to use.
Supply the driver and you'll get another error (or it might even work if everything else is correct).
Supply the driver and you'll get another error (or it might even work if everything else is correct).
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: Sep 2007
Posts: 23
Reputation:
Solved Threads: 0
•
•
•
•
says it all. Toplink can't find the jdbc driver for the database you're telling it to use.
Supply the driver and you'll get another error (or it might even work if everything else is correct).
And yes, i fixed my queries as well
so errors after 15 minutes of code fixing 
Thanks
![]() |
Other Threads in the JSP Forum
- Previous Thread: help with jsp
- Next Thread: List of files with full path in javascript
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web






