Solved

asp to jsp conversion

Posted on 2007-04-09
9
269 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

21 Experts available now in Live!

Get 1:1 Help Now