SWB-Consulting
asked on
asp to jsp conversion
could someone please convert this asp code into jsp:
sConnString = "Provider=SQLOLEDB; Data Source=66.66.666.66,1433; Network Library=test; Initial Catalog=test2;User ID=test3;Password=test4;"
set Conn= server.CreateObject("ADODB .Connectio n")
Conn.Open sConnString
Conn.Execute "exec denza.spx_GenerateSMSMessa ge " & "test"
conn.Close
sConnString = "Provider=SQLOLEDB; Data Source=66.66.666.66,1433; Network Library=test; Initial Catalog=test2;User ID=test3;Password=test4;"
set Conn= server.CreateObject("ADODB
Conn.Open sConnString
Conn.Execute "exec denza.spx_GenerateSMSMessa
conn.Close
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you just cant convert that Database connection string to JSP.
you need to use some JDBC driver to create the connection to your database.
check this link
http://e-docs.bea.com/wls/docs81/jdbc/thirdparty.html#1099135
check this as well
http://support.microsoft.com/kb/313100
http://www.akadia.com/services/sqlsrv_jdbc.html
you need to use some JDBC driver to create the connection to your database.
check this link
http://e-docs.bea.com/wls/docs81/jdbc/thirdparty.html#1099135
check this as well
http://support.microsoft.com/kb/313100
http://www.akadia.com/services/sqlsrv_jdbc.html
ASKER
i am sorry actually this is what i need converted (the string is a little more complex):
sConnString = "Provider=SQLOLEDB; Data Source=66.66.666.66,1433; Network Library=test; Initial Catalog=test2;User ID=test3;Password=test4;"
set Conn= server.CreateObject("ADODB .Connectio n")
Conn.Open sConnString
Conn.Execute "exec denza.spx_GenerateSMSMessa ge " & sBusinessNo & "," & sMobileNo & ",'" & sName & "','" & sEmail & "','" & replace(sMsg,"'","") & "','" & request.ServerVariables("R emote_addr ") & "','" & sValText & "','" & sResult & "'"
conn.Close
sConnString = "Provider=SQLOLEDB; Data Source=66.66.666.66,1433; Network Library=test; Initial Catalog=test2;User ID=test3;Password=test4;"
set Conn= server.CreateObject("ADODB
Conn.Open sConnString
Conn.Execute "exec denza.spx_GenerateSMSMessa
conn.Close
ASKER
ok, so now i get a class not found exception for the class:
com.microsoft.jdbc.sqlserv er.SQLServ erDriver
Actually the rest of the application uses SQL Server all the time so I am wondering why here this problm occurs?
com.microsoft.jdbc.sqlserv
Actually the rest of the application uses SQL Server all the time so I am wondering why here this problm occurs?
ASKER
i checked another file in the application and this is what it does, can I reuse this somehow?:
try {
String DRIVER = config.getInitParameter("D RIVER");
Class.forName(DRIVER);
}
catch (ClassNotFoundException e) {
}
try {
String DBCONN = config.getInitParameter("D BCONN");
qry="SELECT ListingId, BusinessName, BusinessType, BusinessDescription, AlternateName, BrandName, ShortName, CityId, AdvertisingTypeId FROM tb_Directory (nolock) ";
cNum = 9;
countIndex=0;
/***********************/
/* Database Connection */
/***********************/
conn = DriverManager.getConnectio n(DBCONN);
stmt=conn.createStatement( );
java.sql.ResultSet rs = stmt.executeQuery (qry);
try {
String DRIVER = config.getInitParameter("D
Class.forName(DRIVER);
}
catch (ClassNotFoundException e) {
}
try {
String DBCONN = config.getInitParameter("D
qry="SELECT ListingId, BusinessName, BusinessType, BusinessDescription, AlternateName, BrandName, ShortName, CityId, AdvertisingTypeId FROM tb_Directory (nolock) ";
cNum = 9;
countIndex=0;
/***********************/
/* Database Connection */
/***********************/
conn = DriverManager.getConnectio
stmt=conn.createStatement(
java.sql.ResultSet rs = stmt.executeQuery (qry);
ASKER
ok i think i almost figured it out now, i am just getting an error for this line:
cstmt.setString(1, sBusinessNo + "," + sMobileNo + ",'" + sName + "','" + sEmail + "','" + sMsg.replace("'","") + "','" + request.getRemoteAddr() + "','" + /* sValText + */ "','" + /* sResult + */"'");
the error is:
java.sql.SQLException: Invalid parameter index 0.
cstmt.setString(1, sBusinessNo + "," + sMobileNo + ",'" + sName + "','" + sEmail + "','" + sMsg.replace("'","") + "','" + request.getRemoteAddr() + "','" + /* sValText + */ "','" + /* sResult + */"'");
the error is:
java.sql.SQLException: Invalid parameter index 0.
if they are multiple parameters than you shd not do a concat string..
do it following way..
cstmt=conn.prepareCall("de nza.spx_Ge nerateSMSM essage(?,? ,?,?,?,?,? ,?");
cstmt.setInteger(1,sBusine ssNo);
cstmt.setInteger(2,sMobile No);
cstmt.setString(3,sName);
..
...
..
do it following way..
cstmt=conn.prepareCall("de
cstmt.setInteger(1,sBusine
cstmt.setInteger(2,sMobile
cstmt.setString(3,sName);
..
...
..
http://www.netcoole.com/jasp/dbconnect.htm