# coding: utf-8
'''
Created on 02.11.2011

@author: den
'''
from __future__ import with_statement
from ru.curs.showcase.core.jython import JythonProc
from ru.curs.showcase.runtime import ConnectionFactory,AppInfoSingleton
from ru.curs.showcase.util.xml import XMLUtils
import xml.dom.minidom as minidom
from java.io import FileOutputStream,FileInputStream,StringWriter,StringBufferInputStream,ByteArrayInputStream
from java.lang import Class
from com.ziclix.python.sql import zxJDBC, PyConnection
from java.sql import Connection, SQLException, DriverManager
from javax.xml.stream import XMLOutputFactory,XMLStreamWriter
import datetime 

#from org.xml.sax.helpers import DefaultHandler;
#from ru.curs.showcase.util import TextUtils;

# init vars

class aaa(JythonProc):        
    def handle(self, input):
        global request
        request = input
        return mainproc()
        
def mainproc():
    if __name__ == "__main__": 
        Class.forName("org.postgresql.Driver");
        conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/reception","postgres","F708420Dx")
        pyConn = PyConnection(conn)
        # print 'testCon'
    else: 
        pyConn = ConnectionFactory.getPyConnection();
    #pyConn = PyConnection(conn)    
    pyConn.autocommit = True      
    info = pyConn.cursor()
    try:
        queryStr= u'''select * from journals.remind_pass(?)'''
        info.execute(queryStr,[request])
        result=info.fetchone()          
	   
    finally:
        info.close()	
    return result[0]

     
  