Solved

asp to jsp conversion

Posted on 2007-04-09
9
256 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
9 Comments
 
LVL 12

Accepted Solution

by:
Gibu George earned 500 total points
Comment Utility

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
Comment Utility
I think this may help you
http://www.netcoole.com/jasp/dbconnect.htm
0
 
LVL 11

Expert Comment

by:Manish
Comment Utility
0
 
LVL 10

Expert Comment

by:mbvvsatish
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:SWB-Consulting
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now