您的位置:首页 > 科技 > 能源 > 网络营销推广方案的思路及步骤解析_网店美工具体要求_宿州百度seo排名软件_网络推广培训课程内容

网络营销推广方案的思路及步骤解析_网店美工具体要求_宿州百度seo排名软件_网络推广培训课程内容

2025/1/16 18:39:14 来源:https://blog.csdn.net/hcsdny895/article/details/144773364  浏览:    关键词:网络营销推广方案的思路及步骤解析_网店美工具体要求_宿州百度seo排名软件_网络推广培训课程内容
网络营销推广方案的思路及步骤解析_网店美工具体要求_宿州百度seo排名软件_网络推广培训课程内容

package hs.hsapp.util;

import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HanaJdbc {
private static final String DRIVER = “com.sap.db.jdbc.Driver”; //jdbc 4.0
private static final String URL = “jdbc:sap://IP:30041?reconnect=true”;

public List<Map<Object, Object>> select(String sql) {List<Map<Object, Object>> list = new ArrayList<>();try{Connection con = this.getConnection(DRIVER, URL, "USR", "PWD");PreparedStatement pstmt = con.prepareStatement(sql);ResultSet rs = pstmt.executeQuery();//this.processResult(rs);ResultSetMetaData rsmd = rs.getMetaData();int colNum = rsmd.getColumnCount();while (rs.next()) {Map<Object,Object> map = new HashMap<>();for(int i = 1; i <= colNum; i++) {//System.out.println("col: " + rsmd.getColumnName(i) + ",val: " + rs.getObject(i));map.put(rsmd.getColumnName(i),rs.getObject(i));}list.add(map);}this.closeConnection(con, pstmt);}catch (Exception ex) {ex.printStackTrace();}return list;
}private void processResult(ResultSet rs) throws Exception {if (rs.next()) {ResultSetMetaData rsmd = rs.getMetaData();int colNum = rsmd.getColumnCount();for (int i = 1; i <= colNum; i++) {if (i == 1) {System.out.print(rsmd.getColumnName(i));} else {System.out.print("\t" + rsmd.getColumnName(i));}}System.out.print("\n");System.out.println("———————–");do {for (int i = 1; i <= colNum; i++) {if (i == 1) {System.out.print(rs.getString(i));} else {System.out.print("\t"+ (rs.getString(i) == null ? "null" : rs.getString(i).trim()));}}System.out.print("\n");} while (rs.next());} else {System.out.println("query not result.");}}private Connection getConnection(String driver, String url, String user,String password) throws Exception {Class.forName(driver);return DriverManager.getConnection(url, user, password);}private void closeConnection(Connection con, Statement stmt)throws Exception {if (stmt != null) {stmt.close();}if (con != null) {con.close();}
}

}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com