Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connect BigSQL using python
#1
Hello I have to connect & retrieve data from BigSQL using python.I have written a java code for doing that & I'm invoking my java code from python. My java code is following

public class Hello { public static void main(String[] args) { try(Connection con = DriverManager.getConnection("connection details")) { Class.forName("com.ibm.db2.jcc.DB2Driver"); Statement stmt = con.createStatement(); System.out.println("Connected to BigSQL"); ResultSet result = stmt.executeQuery("select * from table limit 10"); while (result.next()) { //Retrieve by com_name String com_name = result.getString(1); //Retrieve by family String family = result.getString(2); //Retrieve by sci_name String sci_name = result.getString(3); //Retrieve by symbol String symbol = result.getString(4); //Retrieve by synonym String synonym = result.getString(5); System.out.println(com_name+":"+family+":"+sci_name+":"+symbol+":"+synonym); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } 
The python code which I'm using to invoke my java code is
[code]import os import os.path,subprocess from subprocess import STDOUT,PIPE path='Location where my .java file is' os.chdir(path) def compile_java(java_file): subprocess.check_call(['javac', java_file]) def execute_java(java_file): java_class,ext = os.path.splitext(java_file) cmd = ['java', java_class] compile_java('Hello.java') execute_java("Hello")[/code]
My python code is running successfully without any error.But I'm not able to get the output of Java in my python console. Can you please help me?
Reply


Messages In This Thread
Connect BigSQL using python - by Learner_Python - May-04-2017, 03:35 PM
RE: Connect BigSQL using python - by Larz60+ - May-04-2017, 05:07 PM
RE: Connect BigSQL using python - by volcano63 - May-04-2017, 07:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  connect sql by python using txt. file dawid294 2 554 Jan-12-2024, 08:54 PM
Last Post: deanhystad
  How to Connect to PostgreSQL Through Jump Server and SSH Tunnel using Python? nishans 1 1,247 Jan-02-2024, 10:37 AM
Last Post: khanzain
  python connect to mssql wailoonho 7 1,955 Dec-07-2023, 02:06 AM
Last Post: wailoonho
  Using Python to connect to an XML ? jehoshua 12 2,179 Jul-11-2023, 12:34 AM
Last Post: jehoshua
  Trying to make a bot to connect on discord with Selenium Python johnsmith43 2 63,315 Mar-21-2022, 02:56 PM
Last Post: Cloudytechnical
  How to connect Mysql databse with python and VSCode IDE madhusoodhananER 1 8,843 Oct-31-2019, 10:15 AM
Last Post: Larz60+
  Connect a Teradata DB to Python OscarBoots 10 9,083 Jan-31-2019, 10:23 PM
Last Post: OscarBoots
  Python connect to Sybase IQ FORTITUDE 1 4,865 Jan-24-2019, 02:14 AM
Last Post: micseydel
  How to connect Atom and Python? Jack_Sparrow 1 3,882 May-01-2018, 10:53 AM
Last Post: Larz60+
  connect to remote database via python script sunstar20 5 5,458 Apr-23-2018, 11:05 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020