Java Groovy Grails 2019. 12. 6. 05:54
import groovy.sql.Sql

    def get_chem_id (String formula){

		def results=""
		def productIds=""
		def resultsList=[:]
		def qstring="select * from sigma_aldrich where Formula ='"+formula+"'"
		def sqlrows = Sql.newInstance('jdbc:mysql://'+mysql_server_ip+':3306/apolex', dbuser, dbpass, 'com.mysql.jdbc.Driver')  
		sqlrows.eachRow(qstring){ row ->  
			resultsList << [id:row.Product_number]
			productIds=row.Product_number
		} 		
		sqlrows.close()
		resultsList.each{println it}
		
		return productIds	
	}	
posted by kimsooil
: