java - This code datasource configurarion in tomme is running without eclipse fine but when i run in eclipse then its giving error -


i using apache tomee datasource connecting mysql java.this work without eclipse(juno) fine when running using eclipse giving error. error can view in url:http://www.docdroid.net/2xuj/errro.txt.html

this tomme.xml file

         <?xml version="1.0" encoding="utf-8"?>             <tomee>               <resource id="jdbc/mydb" type="datasource">                 jdbcdriver com.mysql.jdbc.driver                     jdbcurl jdbc:mysql://localhost:3306/ops                 username root                 password                      jtamanaged true                  </resource>             </tomee> 

and web.xml

            <resource-ref>              <description>mysql datasource example</description>              <res-ref-name>jdbc/mydb</res-ref-name>               <res-type>javax.sql.datasource</res-type>                <res-auth>container</res-auth>             </resource-ref>  

and servlet file containts

                context initcontext = new initialcontext();           context envcontext  = (context)initcontext.lookup("java:/comp/env");             datasource ds = (datasource)envcontext.lookup("jdbc/mydb");           connection conn = ds.getconnection();           statement stmt=conn.createstatement();           resultset rs=stmt.executequery("select * student_master");           while(rs.next())             out.println("the student name is"+rs.getstring("sm_studentname")); 

this code wrote testing only.this code working without eclipse fine , 1 more things when run project in eclipse giving exception of hsqldb not mysql can view full stack trance here. http://www.docdroid.net/2xuj/errro.txt.html

if configure datasource in tomee.xml , eclipse have steps also.

     locate tomee server configuration in workspace / servers(eclipse)      right-click server project , select import      select general - file system , click next      browse <tomee>/conf folder      select following files import: logging.properties, system.properties ,            tomee.xml       click finish import files.        in servers tab, right-click tomee server , select publish publish files eclipse metadata folder 

this work.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -