Solved

asp to jsp conversion

Posted on 2007-04-09
9
301 Views
Last Modified: 2008-02-01
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

      
0
Comment
Question by:SWB-Consulting
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 12

Accepted Solution

by:
Gibu George earned 500 total points
ID: 18880562

Connection conn=null;
            CallableStatement cstmt=null;
            try{
            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
            conn = DriverManager
                        .getConnection(
                                    "jdbc:microsoft:sqlserver://<ipaddressof the server machine>:1433",
                                    "test3", "test4");
            cstmt=conn.prepareCall("denza.spx_GenerateSMSMessage");
            cstmt.setString(1, "test");
            cstmt.execute();
            }catch(Exception e){
                  e.printStackTrace();
            }finally{
                  try{
                  cstmt.close();
                  conn.close();
                  }catch(SQLException sqle){
                        sqle.printStackTrace();
                  }
            }

0
 
LVL 11

Expert Comment

by:Manish
ID: 18880563
I think this may help you
http://www.netcoole.com/jasp/dbconnect.htm
0
 
LVL 11

Expert Comment

by:Manish
ID: 18880564
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 10

Expert Comment

by:mbvvsatish
ID: 18880573
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
0
 

Author Comment

by:SWB-Consulting
ID: 18885730
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      
0
 

Author Comment

by:SWB-Consulting
ID: 18885933
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?
0
 

Author Comment

by:SWB-Consulting
ID: 18886021
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);
0
 

Author Comment

by:SWB-Consulting
ID: 18886138
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.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 18886868
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);
..
...
..
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question