[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

asp to jsp conversion

Posted on 2007-04-09
9
Medium Priority
?
304 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 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

650 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