Link to home
Start Free TrialLog in
Avatar of SWB-Consulting
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.Connection")
            Conn.Open sConnString
            Conn.Execute "exec denza.spx_GenerateSMSMessage " & "test"
            conn.Close

      
ASKER CERTIFIED SOLUTION
Avatar of Gibu George
Gibu George
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Manish
I think this may help you
http://www.netcoole.com/jasp/dbconnect.htm
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
Avatar of SWB-Consulting
SWB-Consulting

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.Connection")
            Conn.Open sConnString
            Conn.Execute "exec denza.spx_GenerateSMSMessage " & sBusinessNo & "," & sMobileNo & ",'" & sName & "','" & sEmail & "','" & replace(sMsg,"'","") & "','" & request.ServerVariables("Remote_addr") & "','" & sValText & "','" & sResult & "'"
            conn.Close      
ok, so now i get a class not found exception for the class:
com.microsoft.jdbc.sqlserver.SQLServerDriver

Actually the rest of the application uses SQL Server all the time so I am wondering why here this problm occurs?
i checked another file in the application and this is what it does, can I reuse this somehow?:

try {
                  String DRIVER = config.getInitParameter("DRIVER");
                  Class.forName(DRIVER);  
          }
            
            catch (ClassNotFoundException e) {
          }

            
            try {
                  String DBCONN = config.getInitParameter("DBCONN");
                  qry="SELECT ListingId, BusinessName, BusinessType, BusinessDescription, AlternateName, BrandName, ShortName, CityId, AdvertisingTypeId FROM tb_Directory (nolock) ";
                     cNum = 9;
                     countIndex=0;

                   /***********************/
                   /* Database Connection */
                   /***********************/
                   
                conn = DriverManager.getConnection(DBCONN);
                   stmt=conn.createStatement();
                   
                   java.sql.ResultSet rs = stmt.executeQuery (qry);
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.
if they are multiple parameters than you shd not do a concat string..

do it following way..

cstmt=conn.prepareCall("denza.spx_GenerateSMSMessage(?,?,?,?,?,?,?,?");
cstmt.setInteger(1,sBusinessNo);
cstmt.setInteger(2,sMobileNo);
cstmt.setString(3,sName);
..
...
..