Database connectivity in struts with mysql
Hi,
I want to database connectivity in struts with mysql in struts-config.xml file. I have give the code in struts-config.xml file is given below...................
<data-sources>
<data-source key="dbname" type="org.apache.commons.dbcp.BasicDataSource" >
<set-property property="driverClassName" value="com.mysql.jdbc.Driver" />
<set-property property="url" value="jdbc:mysql://localhost:3306/antrowinnovation" />
<!-- <set-property property="username" value=""/>
<set-property property="password" value="indra" /> -->
</data-source>
</data-sources>
And give the code in Action class is given below...
int i=0;
Connection con;
Statement stmt;
DataSource dataSource = (DataSource)servlet.getServletContext().getAttribute("dbname");
System.out.println(dataSource);
try{
System.out.println("Database connecting....");
con=dataSource.getConnection();
stmt=con.createStatement();
System.out.println("Database connected....");
i=stmt.executeUpdate("insert into login values('" + username + "','" + password + "')");
System.out.println("Values inserted....");
}catch(Exception e){
System.out.println(e.getMessage());
System.out.println("Exception in try");
e.printStackTrace();
return 0;
But when i have run this then i got this Exception....
INFO: Initialize action of type: login.LoginAction
null
Database connecting....
null
Exception in try
java.lang.NullPointerException
at login.LoginAction.insertUser(LoginAction.java:27)
at login.LoginAction.execute(LoginAction.java:47)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:743)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Plz help me..
Read some Struts tutorial.
Similar Messages
-
Connection pool issues with Mysql
Hi,
I have defined sufficient read connections (50) in the toplink configuration, I am finding toplink is not releasing the connections in Mysql, this is when run from Jboss App server.
Is anyone aware of toplink connection pool issues with MySql?
thanksTopLink always closes connections, I cannot see how this could occur.
Please include your persistence.xml or sessions.xml. Also ensure you are closing your EntityManager or ClientSession, especially if using exclusive connections.
Also include the exception you are getting.
James : http://www.eclipselink.org -
Connection of Forms6i with MySQL database
Hi all,
Can any knows how to connect Form builder to MySQL Database.
I'am using Oracle Form builder 6i
and MySQL 3.23 Under Windows NT 4.0( Service pack 5a)
Pls give me your valuable suggestion
Regards,
Seemause odbc
-
Connecting Crystal report with MySql
Post Author: brajbhushan
CA Forum: Data Connectivity and SQL
hi all
i m trying to connect crystal reports XI Release 2 to MySql 5.0 using ODBC.Problem is that after connecting it successfully it shows only few fields of our table in database when i see it in Database Expert of Crystal Reports. The second problem is that the fields don't have any data with them. Can anyone guide me is there any problem with Crystal Reports while connecting to MySql. Is there any Compatibilty Problem of DataType in Crystal Reports while using MySql.
ThanksMoved to .NET SDK forums
First issue is CR 10 has not been tested nor is it supported in VS 2010.
To use CR in VS 2010 download [CR for VS 2010|Crystal Reports for Visual Studio 2010 Production Release Now Available;
Likely what your problem is is you are not setting or replacing the database connection info but without more info I can't suggest how to fix it. It could also be that you have set your framework to 4.0, CR 10 is FW 1.1 or possibly 2.0 only.
Or you may even be trying to use the craxddrt.dll which is again no longer supported not are you licensed to use it or distribute it.
Also you'll likely run into version problems with IIS. I believe CR 10 only supported IIS 5 but check the platforms PDF for more info.
Good luck.
Don -
Database connection dailog opens with missing fields
Greetings all,
I have one user who has a couple reports that do not display all the fields in the database connection dialog box when she attempts to refresh the data in a report.
Normally this dialog box opens with the Datasource, UserID (of the last person who saved data with the report) and Database prefilled, so only the Password needs to be completed or the UserID changed.
For her (and this is only happening on a couple reports), only the Datasource text box is visible. The datasource is correctly filled in but in order to see the other fields, she needs to click the next button and then click back. Then all three fields - UserID, Password and Database need to be entered.
This only started in the past couple months and so far is only occuring with 2 reports, both new. Other new reports are acting normally.
We are using Crystal Reports XI with the latest service packs. Our reports are in a shared folder on the network. So far I have not been able to duplicate this behavior on anyone else' machine.
Any idea's on what might be causing this or how to correct it?
TIA,
BobI would check that persons database client and/or version of MDAC. May also be a permission issue on tables.
-
Database connectivity toolkit problem with WINDOWS VISTA and Microsoft jet 4.0 provider
Hi again,
I'm experiencing a problem with Database connectivity toolkit and Microsoft Jet 4.0 provider (MS ACCESS mdb database).
I was able to get my application to work properly on my PC: WINDOWS XP PROFESSIONAL, VERSION 2002, SERVICE PACK 3 and Msjet40.dll ver. 4.0.9511.0 (Windows XP SP3 and Security Bullettin MS08-028).
The same connectivity toolkit seems to have problems (although I didn't get any error dialog) on a laptop with WINDOWS VISTA ULTIMATE, SERVICE PACK 2 and Msjet40.dll ver. 4.0.9755.0.
Does anyone have an idea whether it is a sort of compatibility issue or a different thing?
Would it be possible to include my DLLs into the installer in such a way LabVIEW application calls those DLLs instead of the ones it finds on the host PC?
Thanks a lot. Any suggestion or advice very welcome and appreciated.I ran into this with Windows7 64 but, could not get the jet 4.0 to work. Endnd up dumping access and used sql server express, its free, and all my code worked fine, just used a different UDL to connect. I wasted lots of time trying to find a way of getting the jet4.0 to work with 64bit windows.
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA -
Database connectivity in struts ( EJB) with Oracle 9
hi,
We are developing a Banking application using Struts & EJB, & I need to use Oracle 9 as a database. Could anyone please let me know, the professional way of connecting this application to the oracle database using Struts and EJB. A good example will help me a lot, so please give me example code also.
Thanks a lot in advance.
RaghavHello,
For keeping the standby database on same HOST....it does seems to be great...i must be on separate box....may be on different network...i believe you would be using it for some failiover purpose...Isn't it.
For Unix it is quite easy..you may implement like this...The Issue which you are referring may be because of wrong Oracle Home or SID....(i'm not very much sure..) You may try following steps:
1. Create a separate Unix A/c and set ORACLE_HOME and ORACLE_SID relevant to your StandBy Database. I believe the Home would be same whereas SID would be your standby databse.
2. Take a Cold Backup of All your database files from Production.
3. Copy these files on separate mount points for standby Db. Put them all to relevant directory and be sure to set the Group of all these files as "SYSDBA" This is Must.
4. And then modify your INIT.ORA file i.e. InitSID.ora file accordingly and put the file in ORACLE_HOME
5. Login to Newly created Unix A/c. Check whether ORACLE_SID is set ot not to your standby database instance.
6. Login to sys as sysdba and start up the database. It will by default would try to check & do for your relevant Oracle SID for this profile...
HTH
Regards,
Kamesh Rastogi -
Connecting Oracle 11g with MySQL 5.1
Hey all,
I've been looking all over the web for this, and I can't find any information that applies to my case. I have an Oracle 11g DB setup on a Windows Server 2003 SP2, and have installed the Heterogeneous services ODBC driver. I want to connect this to another Windows 2003 SP2 machine that runs MySQL Community.
On the Oracle side, I have configured the ODBC Systems connection to MySQL, and it connects successfully. I have also configured tnsnames.ora as follows:
mysqlecommerce=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=dvlps11.cosine.com.cy)
(PORT=1521)
(CONNECT_DATA=
(SID=mysql_gateway))
(HS=OK))
I have initmysql_gateway.ora with the following two lines:
HS_FDS_CONNECT_INFO = mysqlecommerce
HS_FDS_TRACE_LEVEL = ODBC
and I have included the following into the listener.ora file:
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=mysql_gateway)
(ORACLE_HOME=C:\Oracle11g\product\11.1.0\db_1)
(PROGRAM=dg4odbc)
I have also created a dblink as follows:
create public database link "MYSQLECOMMERCE"
connect to MYSQLDB
identified by "<pwd>"
using 'mysqlecommerce';
Now when I try to run a simple SQL selection such as:
select "id_category" from "ps_category"@mysqlecommerce
I get the following reply:
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[MySQL][ODBC 5.1 Driver][mysqld-5.1.36-community-log]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"id_category" FROM "ps_category" A1' at line 1
ORA-02063: preceding 2 lines from DG4ODBC
Can anyone please help me understand what is going on?
Thank you in advance!The syntax error is caused by your MySQL database not running in ANSI mode. By default DG4ODBC sends ansi compliant code to the foreign database and this means for case sensitive column and table names it surrounds them by double quotes. MySQL db not running in ANSI compliant mode rejects them and uses a back tick to preserver the case - thus it reports a syntax error in case of double qoutes.
To solve the issue please have a look at My Oracle Support note:
Problems Selecting Mysql Data Using 11.1.0.6 DG4ODBC - Error In Your SQL Syntax [ID 553030.1] -
Hi friends,
I am making a web site for a customer and i need to import
data from MySQL Database but i don't know how to do it.
I would appreciate it if somebody could give me an idea or
tell me where to find a tutorial.
Also i heard that there is a .dll file that Macromedia made,
in order to make it easier to connect Flash with Databases, is that
true ?You'll need a server-side scripting language, like PHP, to
query your
database and format the data for Flash. If AS2 you use the
LoadVars class
for this. You might also check out www.amfphp.org which is an
alternative to
remoting, and allows you to call functions directly on the
server. Once you
use it for a while, it makes LoadVars clunky.
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
ADO Database Connection: Need help with correct syntax for 'Execute' Method
My server Windows 2008R2 taking more than 30 hours to complete backup
so next backup getting fail
is there any option to set start backup after 24 hours if previous backup completeI have a script that I am trying to cobble together, but I am stuck at attempting to execute an SQL query against and ADO connection. My code is as follows:Powershell $FQDNUpper = $Computer.ToUpper() + ".domain.dn1.dn2" $FQDNLower = $Computer.ToLower() + ".domain.dn1.dn2" $shell = New-Object -ComObject "Wscript.Shell" # for use later in script $cnn = New-Object -ComObject "ADODB.Connection" $cnn.ConnectionString = "Connection_String" $cnn.Open() $query = "SELECT CAST(ID AS nvarchar(50)) ID FROM Machine WHERE Name=$FQDNUpper AND Role = 0" $rs = $cnn.Execute($query,' ',1) #If statement that will qualify if $FQDNUpper returned anything else try $FQDNLowerWhen executing the code I receive an error:
PowershellArgument: '2' should be a System.Management.Automation.PSReference. Use [ref].At line:9 char:5+ $rs = $cnn.Execute($query,' ',1)+ ... -
Database connectivity problem with instant client.
Guys,
I've installed the Oracle instant client basic and ODBC files in my system.
But when I create a system DSN and test the connectivity my database connectivity,it fails with
ORA-12637:Packet receive failed error
My TNSNAMES reads below:
ONDSP101.DIGITALINDIASW.NET =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = namesrv1.xy.zz.com)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ONDSP101)
and my SQLNET as below:
AUTOMATIC_IPC = OFF
TRACE_LEVEL_CLIENT = ON
SQLNET.INBOUND_CONNECT_TIMEOUT=20
NAMES.DEFAULT_DOMAIN = na.pg.com
NAME.DEFAULT_ZONE = na.pg.com
SQLNET.CRYPTO_SEED = "kdg:9yv2$-plo*u6b2x!"
NAMES.DIRECTORY_PATH = (ONAMES,TNSNAMES)
NAMES.PREFERRED_SERVERS =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = TCP.xy.zz.com)
(PROTOCOL = TCP)
(Host = namesrv1.xy.zz.com)
(Port = 1522)
(ADDRESS =
(COMMUNITY = TCP.xy.zz.com)
(PROTOCOL = TCP)
(Host = namesrv2.xy.zz.com)
(Port = 1522)
I've placed my TNSNAMES and SQLNET file in the same folder having the instant client files and I've set my TNSADMIN,LD_LIBRARY_PATH and PATH environmental variable to the folder location.
Note:I'm able to connect to the database using SQLplus.
Thanks,
Bhagat12637, 00000, "Packet receive failed"
// *Cause: A process was unable to receive a packet from another process.
// Possible causes are:
// 1. The other process was terminated.
// 2. The machine on which the other process is running went down.
// 3. Some other communications error occurred.
// *Action: If the cause is not obvious, contact Oracle Customer Support.
These days I very seldom use ODBC for Oracle - most recently it was simply to get Enterprise Architect to "talk" to Oracle. I never used it for my client applications (unlike in the fast distant past), so what I know about ODBC is seriously outdated.
Even so, a few comments. :-)
Have you tried creating a user DSN, in case a system DSN somehow works different environment wise?
The above error description sounds like the original TCP connection was successful (i.e. it is not a host unknown or not reachable error). Subsequent packets seem to fails.
To confirm, run the listener on namesrv1.xy.zz.com with logging enabled and have a look at the listener.log - does it show a connection being accepted/handled from your PC when you use the ODBC DSN?
Have you tried the Oracle ODBC drivers? When getting EA connected I had problems (also with Instant Client) and Microsoft ODBC driver for Oracle. Downloaded and installed the Oracle ODBC driver and it worked just fine first time around.
PS. You should raise this topic on the Instant Client Forum instead. -
Problem with USERNAME & PASSWORD creation--JDBC connection with MYSQL
How to connect to JDBC with Mysql Connector
i installed mysql & created table, it works fine
During Password---> I gave it as tiger , no username
i installed mysql connector
i saved the .jar file path in class path
HOW TO CREATE USERNAME & PASSWORD & DATASOURCE NAME ---> Is it the password -tiger or something else like (ADMinstrative tools-ODBC-services--etc )
Pl, help,
tks
XxHow to connect to JDBC with Mysql Connector
i installed mysql & created table, it works fine
During Password---> I gave it as tiger , no usernameTiger? This ain't Oracle.
I think you should give a username and password. How can it look up a password without a username? Better GRANT the right permissions, too.
Read the MySQL docs a bit more closely. Your path isn't the way to go.
% -
Why the err Invalid database Connection -CR 11 version in Visual studio 1.1
Hai all,
I am new to using the Crystal report with Visual studio 2003.I am facing Invalid database connection problem. My objective is tyring to upgrade CR 8 to CR11 with VS 1.1 framework(VC++ in .NET 2003).All things like ODBC connection with MS SQL server 2005,generating report going fine with CR8 version but invalid database connection error comes with CR11 version. The configuration details and Code snippet are below for your ref,
Upgrading CR8 to CR11 with VS .NET 2003.
Application framework - VS 1.1 framework
CR - 11 Version
DB - MS SQL server 2005
Connection - ODBC
DLL - CRPE32 DLL (Version11)
Code snippet:
CODBCDatabase * pDatabase = pApp->GetDatabase();
BOOL bRes;
bRes = ::PELogOnSQLServerWithPrivateInfo(_T("pdsodbc.DLL"), pDatabase->m_hdbc);
Note: pdsodbc dll not found in local and anywhere.But it supports CR 8 but not CR 11.So i downloaded and put it in appropriate place exe path\system32\system and tested.Used and tested p2sodbc dll also but "Invalid DataBase connection" err came.Followed some instruction like changing the Data source name,DSN path,re installing CR 11 version and all but same problem coming.
::PELogOnSQLServerWithPrivateInfo() declation is in the following link
http://www.arcaretentores.com.br/FTP/Format/Report/ProgramF/SEAGAT~1/CRW/DEV/Help/HTML/12a_0708.htm
Thanks in advance
Regards
SatheeshKumar
India.Thanks for your reply
The API i have given is not available in Crystal report 11.So i tried with the PELogonServer API of version 11.It also failed.
I am unable to understand the suggestions you gave to me 1) The Report Designer Component (RDC)
2) The CR Assemblies for .NET.
Can you give any link that have related samples or articles to implement the above topics please?
Thanks again,
Satheesh Kumar.D -
How to create JDBC connection in J2ME with MS-SQL server?
I need to have database connection in PDA with SQL server,as i am new to J2ME ,i dont know how to create jdbc connection on J2ME device.Please help me out with this problem........
I need to have database connection in PDA with SQL server,as i am new to J2ME ,i dont know how to create jdbc connection on J2ME device.Please help me out with this problem........
-
Production and Development Database Connections
Within JDeveloper I have created a database connection to a DEVELOPMENT database and am exposing PL/SQL packages in the development database as web services.
I can develop and test successfully the exposed packages as web services, and can deploy and run them to a standalone OC4J container on my local machine.
I then handover the generated EAR file to the production team who deploy the EAR as a web service to the Oc4j container in a remote 9i Application Server.
This runs successfully from 9iAS.
So far so good.
If I have the same PL/SQL package in a live database and development database, but only have access to the development database, how can I expose the package in the live database?
Can I have a database connection in JDeveloper with a connection name pointing to the development database connection, and have a connection defined in 9iAS with the same name pointing to the live database?
Any information will be useful.
Thanks,
Claire.Per the J2EE "roles" definition this is a deployment role todo.
I.E. the theory is; take a 3rd party ear, depoyee with your appserver vendor's
deployment tool, edit the data-sources.xml imbeded in the ear on the fly, as
deployment happens.
Bake to reality-
OC4J 903 is intended to be used with OEM for the J2EE spec'ed role of deployer. I'm
headed this way, but not started the 903/OEM todo.
Today, OC4J 902 and 902 Jdev, I deploy to a local instance of OC4J. I take that
ear to production. I've written procedural instructions on poping open the ear and
editing the data-sources.xml for the DB connection URL and possible login/passwords.
BTW all your AppModule configurations will have to use data-sources DB connections else
you'll have DB connection info littered in your bc4j.xcfg's for each AM deeper in your war's.
I'd like to hear how this is supposed to work from some other folks? :)
Good luck,
curt
Maybe you are looking for
-
MSI RD480 Neo2 : HT Link Speed
I've just discovered the HT Link Speed limitation in the current 3.2 bios for the MSI RD480 Neo2 and was wondering if MSI is able/going to fix this issue? and add if possible the 2x,3x,4x,etc HTT links?? Previously this was not an issue since i had a
-
Get date AND time to show in the menu bar
What is that technique to get date AND time to show in the menu bar please?
-
I havev installed a new Hard Drive on my laptop but cannot find my Photoshop Elements product box with the serial number to install Elements 10 or Elememts Premier 10. How can I find out the serial / installation codes for these? I saw a reply howeve
-
Problem with jdbc- Oci8 driver
Hi there, I am using oracle client of version 8.1.5 and jdk1.2.2, classes12.zip in the classpath of my NT. I can able to establish the database connectivity using thin driver.. But for Oci driver, it is not working.. I have given piece of code below.
-
Substitution Relation A210/B210
For position based substitution a relation ship is generated in the PD infotype hrp1001 ( with A210 who is the actual approver and B210 who is the substitute ) after this, does the substitutee can see the inbox of the approver or do I need to push t