How to Return the Output Value from Vbs File to java class

694 views
Skip to first unread message

Venkat Kandula

unread,
Dec 19, 2014, 4:17:01 AM12/19/14
to mercu...@googlegroups.com

Hi All,

I am facing typical scenario is how to return the value from vbs file to java class.

Please see the below code for better understanding...

Vbs Code:

RetrunValue=DBConnction()

Function DBConnction()

Dim objConnection
 'Set Adodb Connection Object
 Set objConnection = CreateObject("ADODB.Connection")    
 Dim objRecordSet

 'Create RecordSet Object
 Set objRecordSet = CreateObject("ADODB.Recordset")    
 Dim DBQuery 'Query to be Executed
 DBQuery = "Select NAME from dbo.EMPLOYEE where AGE = 29"
 'Connecting using SQL OLEDB Driver
 objConnection.Open "Provider=sqloledb;Server=10.91.64.12;User Id=sa;Password=sunp@55;Database=VIMS"
 'Execute the Query
 objRecordSet.Open DBQuery,objConnection
 'Return the Result Set
 Value = objRecordSet.fields.item(0)               
 'msgbox Value
 DBConnction=Value
 ' Release the Resources
 objRecordSet.Close       
 objConnection.Close       
 Set objConnection = Nothing
 Set objRecordSet = Nothing
 End Function

Java Code:

package programs;

public class DBConnection {

    public static void main(String[] args) {
        try
        {               
            Process p= Runtime.getRuntime().exec("wscript.exe C:\\Users\\venkatak\\Desktop\\DBConnection.vbs");
            p.getOutputStream().toString();
        }
        catch(Exception e)
        {
         e.getMessage();
        }
    }
}

I am able to invoke the DBConnection.vbs file and execute that file and print the file. I would like to use those vbs output file inot our java class.

Please let me know if you have any idea about these concepts.

Thanks,
Venkat
Reply all
Reply to author
Forward
0 new messages