MySql Connection Problem

I am trying to make a connection but it returns error.I am following the instruction in the tutorial but i cant figure the problem.any help will be highly appreciated.Thanks

package com.example.database;

import java.sql.SQLException;

import com.vaadin.data.util.sqlcontainer.SQLContainer;
import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
import com.vaadin.data.util.sqlcontainer.query.TableQuery;

public class databasehelper {
	private SQLContainer person= null;
	private SQLContainer medicine= null;
	SimpleJDBCConnectionPool connectionPool;	
	public databasehelper(){
		init();
		initcontainer();		
	}

	
	private void init() {
		// TODO Auto-generated method stub
		
		try {
			connectionPool = new SimpleJDBCConnectionPool(
			         "com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/database",
			         "root", "nomi", 2, 2);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	private void initcontainer(){
		TableQuery q1 = new TableQuery("persont",connectionPool);
		try {
			person= new SQLContainer(q1);
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		TableQuery q2 = new TableQuery("Medicine",connectionPool);
		try {
			medicine = new SQLContainer(q2);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}

Hi,

Any of the error messages will be highly appreciated.Thanks :slight_smile:

"com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/database",
TableQuery q1 = new TableQuery("persont",connectionPool);

Did the driver load, or do you get a Class-Not-Found exception?
Is the name of your database really ‘database’?
Is the name of your table really ‘persont’?

greetings
Ralf

this is the error

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: java.lang.RuntimeException: Specified JDBC Driver: com.mysql.jdbc.Driver - initialization failed.
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.handleServiceException(AbstractApplicationServlet.java:1010)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:548)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

java.lang.RuntimeException: Specified JDBC Driver: com.mysql.jdbc.Driver - initialization failed.
	com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool.<init>(SimpleJDBCConnectionPool.java:74)
	com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool.<init>(SimpleJDBCConnectionPool.java:82)
	com.example.database.databasehelper.init(databasehelper.java:25)
	com.example.database.databasehelper.<init>(databasehelper.java:14)
	com.example.database.DatabaseApplication.init(DatabaseApplication.java:10)
	com.vaadin.Application.start(Application.java:551)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1219)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:484)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
	java.lang.ClassLoader.loadClassInternal(Unknown Source)
	java.lang.Class.forName0(Native Method)
	java.lang.Class.forName(Unknown Source)
	com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool.<init>(SimpleJDBCConnectionPool.java:72)
	com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool.<init>(SimpleJDBCConnectionPool.java:82)
	com.example.database.databasehelper.init(databasehelper.java:25)
	com.example.database.databasehelper.<init>(databasehelper.java:14)
	com.example.database.DatabaseApplication.init(DatabaseApplication.java:10)
	com.vaadin.Application.start(Application.java:551)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1219)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:484)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Hi,

root cause 
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

There we are: The MySQL JDBC driver is missing at run time.
You need to add the jar to the build path, and make sure,
it can be found at run time, check deployment settings.

greetings
Ralf

Hi

I am a newbie using vaadin. i have solved the problem above but during the deployment, I got this error:

=================================================================
Mar 12, 2013 2:02:20 PM com.vaadin.server.DefaultErrorHandler doDefault
SEVERE:
java.lang.AbstractMethodError
at com.vaadin.ui.AbstractSelect.setContainerDataSource(AbstractSelect.java:1000)
at com.vaadin.ui.Table.setContainerDataSource(Table.java:2658)
at com.vaadin.ui.Table.setContainerDataSource(Table.java:2628)
at com.example.chartproject.ChartprojectUI.init(ChartprojectUI.java:98)
at com.vaadin.ui.UI.doInit(UI.java:523)
at com.vaadin.server.AbstractCommunicationManager.getBrowserDetailsUI(AbstractCommunicationManager.java:2464)
at com.vaadin.server.AbstractCommunicationManager.handleBrowserDetailsRequest(AbstractCommunicationManager.java:2359)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:325)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.ja

I have tried adding different version of mysql connector but no success…

Thanks

Something in your project has been compiled against a different (incompatible) version of some library that you are using at runtime, or maybe you have multiple versions of a library on your classpath.

Based on the stack trace, most likely the problem is between Vaadin and the container implementation you are using. If you are using a container that is in the Vaadin JAR, you have two different versions of Vaadin on your classpath.

sir i am using the same database helper class for sql container,

there were four steps in this class,

  • connecting to mysql data base — done

  • intializing data base ---- done

  • initializing containers, — done

  • filling the container ,putting data into container,
    i am pasting here the code which exactly gives an error,

Object id = personContainer.addItem();
personContainer.getContainerProperty(id, “FIRSTNAME”)
.setValue(firstName);
personContainer.getContainerProperty(id, “LASTNAME”)
.setValue(lastName);

this is the code in fill container method,
this gives the following error

HTTP Status 500 - java.lang.NoClassDefFoundError: com/vaadin/data/Property$ConversionException


type Exception report

message java.lang.NoClassDefFoundError: com/vaadin/data/Property$ConversionException

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/vaadin/data/Property$ConversionException
com.vaadin.server.VaadinServlet.handleServiceException(VaadinServlet.java:580)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:343)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

root cause

java.lang.NoClassDefFoundError: com/vaadin/data/Property$ConversionException
com.vaadin.addon.sqlcontainer.SQLContainer.addItem(SQLContainer.java:137)
com.vaadin.tutorial.addressbook.DatabaseHelper.fillContainers(DatabaseHelper.java:127)
com.vaadin.tutorial.addressbook.DatabaseHelper.(DatabaseHelper.java:48)
com.vaadin.tutorial.addressbook.AddressbookUI.init(AddressbookUI.java:57)
com.vaadin.ui.UI.doInit(UI.java:529)
com.vaadin.server.AbstractCommunicationManager.getBrowserDetailsUI(AbstractCommunicationManager.java:2468)
com.vaadin.server.AbstractCommunicationManager.handleBrowserDetailsRequest(AbstractCommunicationManager.java:2362)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:325)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

root cause

java.lang.ClassNotFoundException: com.vaadin.data.Property$ConversionException
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1713)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
com.vaadin.addon.sqlcontainer.SQLContainer.addItem(SQLContainer.java:137)
com.vaadin.tutorial.addressbook.DatabaseHelper.fillContainers(DatabaseHelper.java:127)
com.vaadin.tutorial.addressbook.DatabaseHelper.(DatabaseHelper.java:48)
com.vaadin.tutorial.addressbook.AddressbookUI.init(AddressbookUI.java:57)
com.vaadin.ui.UI.doInit(UI.java:529)
com.vaadin.server.AbstractCommunicationManager.getBrowserDetailsUI(AbstractCommunicationManager.java:2468)
com.vaadin.server.AbstractCommunicationManager.handleBrowserDetailsRequest(AbstractCommunicationManager.java:2362)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:325)
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:201)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

See my previous message in this thread - a classpath conflict or incompatible versions of libraries or some libraries not deployed to the server.

Please do not post questions to old threads that are unrelated to the issue and just happen to use the same word. Also, please do not post the same question multiple times.

Hello dags Barboza

How did you solve the problem? I’ve added “mysql-connector-java-5.1.36-bin.jar” in my project’s Build Path, but I still get the same error:

WARNING:

Vaadin is running in DEBUG MODE.
Add productionMode=true to web.xml to disable debug features.
To show debug window, add ?debug to your application URL.

java.lang.RuntimeException: Specified JDBC Driver: com.mysql.jdbc.Driver - initialization failed.
at com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool.(SimpleJDBCConnectionPool.java:74)
at com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool.(SimpleJDBCConnectionPool.java:82)
at com.example.myproject.MyprojectUI.init(MyprojectUI.java:46)
at com.vaadin.ui.UI.doInit(UI.java:675)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:214)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:351)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1526)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1482)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool.(SimpleJDBCConnectionPool.java:72)
… 30 more

I’m using Vaadin 7, Eclipse 3.8 and Tomcat 8.0.26 running on Raspberry Pi 2