当前位置: 首页>>代码示例>>Java>>正文


Java SQLException.printStackTrace方法代码示例

本文整理汇总了Java中java.sql.SQLException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java SQLException.printStackTrace方法的具体用法?Java SQLException.printStackTrace怎么用?Java SQLException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.SQLException的用法示例。


在下文中一共展示了SQLException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * 传入的SQL语句只能是INSERT,DELETE,UPDATE和DDL语句
 *
 * @param sql 相应SQL语句
 * @param arg 传入的占位符的参数
 */
public static void update(String sql, Object... arg) {
    Connection connection = JDBCUtils.getConnection();
    PreparedStatement ps = null;
    try {
        ps = connection.prepareStatement(sql);
        for (int i = 0; i < arg.length; i++) {
            ps.setObject(i + 1, arg[i]);
        }
        ps.executeUpdate();
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    JDBCUtils.release(ps, connection);
}
 
开发者ID:FlyingHe,项目名称:UtilsMaven,代码行数:23,代码来源:DBUtils.java

示例2: deleteZonaGeografica

import java.sql.SQLException; //导入方法依赖的package包/类
public static void deleteZonaGeografica(String id, String tipo_zona_geografica_id){
 	 Connection conect=ConnectionConfiguration.conectar();
 	 Statement statement = null;
 String 							query = "delete from zona_geografica ";
 //if (id!="")						query+= "id=\""+id+"\", ";
 /*if (nombre!="")					query+= "nombre=\""+nombre+"\", ";
 if (descripcion!="")				query+= "descripcion=\""+descripcion+"\", ";
 if (abrev!="")						query+= "abrev=\""+abrev+"\", ";
 //if (tipo_zona_geografica_id!="")	query+= "tipo_zona_geografica_id=\""+tipo_zona_geografica_id+"\", ";
 if (cod_geo_unif!="")				query+= "cod_geo_unif=\""+cod_geo_unif+"\", ";
 query = query.substring(0, query.length()-2);*/
 query+="where id="+id+" and tipo_zona_geografica_id="+tipo_zona_geografica_id;
		
try {
	statement=conect.createStatement();
	statement.execute(query);
    conect.close();
} catch (SQLException e) {e.printStackTrace();}
 }
 
开发者ID:stppy,项目名称:spr,代码行数:20,代码来源:SqlDelete.java

示例3: updateEjeEstrategico

import java.sql.SQLException; //导入方法依赖的package包/类
public static void updateEjeEstrategico(String id, String nombre,
		String descripcion, String plan_id) {
	Connection conect = ConnectionConfiguration.conectar();
	Statement statement = null;
	String query = "update eje_estrategico set ";
	// if (id!="") query+= "id=\""+id+"\", ";
	if (nombre != "")
		query += "nombre=\"" + nombre + "\", ";
	if (descripcion != "")
		query += "descripcion=\"" + descripcion + "\", ";
	// if (plan_id!="") query+= "plan_id=\""+plan_id+"\", ";
	query = query.substring(0, query.length() - 2);
	query += "where id =" + id + " and plan_id=" + plan_id;

	try {
		statement = conect.createStatement();
		statement.execute(query);
		conect.close();
	} catch (SQLException e) {
		e.printStackTrace();
	}
}
 
开发者ID:stppy,项目名称:spr,代码行数:23,代码来源:SqlUpdates.java

示例4: store

import java.sql.SQLException; //导入方法依赖的package包/类
public void store(Result result){
    Pattern pattern1 = Pattern.compile("https://www.zhihu.com/question/\\d+");
    if(pattern1.matcher(result.getPage().getRequest().getUrl()).matches()){
        Question question = (Question) result.getData("data");
        try {
            Connection connection = DBUtil.getConnection();
            PreparedStatement statement = connection.prepareStatement("insert into question(question_name,question_url,followers,browseNum) values (?,?,?,?)");
            statement.setString(1,question.getQuestionName());
            statement.setString(2,question.getQuestionUrl());
            statement.setInt(3,question.getFollowers());
            statement.setInt(4,question.getBrowseNum());
            statement.executeUpdate();
            statement.close();;
            connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:StevenKin,项目名称:ZhihuQuestionsSpider,代码行数:20,代码来源:Storer.java

示例5: insertLineasTransversales

import java.sql.SQLException; //导入方法依赖的package包/类
public static void insertLineasTransversales(int id, String nombre, String descripcion, int plan){
 	 Connection conect=conectar();
 String query = " insert into linea_transversal (id, nombre, descripcion,plan)"
	        + " values (?,?,?,?)";
try {
	
	PreparedStatement preparedStmt;
	preparedStmt = conect.prepareStatement(query);
	
	preparedStmt.setInt (1, id);
	preparedStmt.setString (2, nombre);
	preparedStmt.setString (3, descripcion);
	preparedStmt.setInt (4, plan);
	preparedStmt.execute();
    conect.close();
} catch (SQLException e) {e.printStackTrace();}
 }
 
开发者ID:stppy,项目名称:spr,代码行数:18,代码来源:SqlHelper.java

示例6: insertModuloHasPermiso

import java.sql.SQLException; //导入方法依赖的package包/类
public static void insertModuloHasPermiso(ModuloHasPermiso moduloHasPermiso, String usuarioResponsable){
	try {
		Connection conn=ConnectionConfiguration.conectar();
	   	
		String query = " insert into modulo_has_permiso (role_id,modulo_id,permiso_id, usuario_responsable)"
		+ " values (?, ?, ?, ?)";
		
		PreparedStatement insert = conn.prepareStatement(query);
		
		insert.setInt (1, moduloHasPermiso.getRole_id());
		insert.setInt (2, moduloHasPermiso.getModulo_id());
		insert.setInt (3, moduloHasPermiso.getPermiso_id());
		insert.setString (4, usuarioResponsable);
							
		insert.execute();
		   
		conn.close();
	} catch (SQLException e) {e.printStackTrace();}
		
}
 
开发者ID:stppy,项目名称:spr,代码行数:21,代码来源:SqlInserts.java

示例7: updateTipoZonaGeografica

import java.sql.SQLException; //导入方法依赖的package包/类
public static void updateTipoZonaGeografica(String id, String nombre,
		String descipcion) {
	Connection conect = ConnectionConfiguration.conectar();
	Statement statement = null;
	String query = "update tipo_zona_geografica set ";
	// if (id!="") query+= "id=\""+id+"\", ";
	if (nombre != "")
		query += "nombre=\"" + nombre + "\", ";
	if (descipcion != "")
		query += "descipcion=\"" + descipcion + "\", ";
	query = query.substring(0, query.length() - 2);
	query += "where id=" + id;

	try {
		statement = conect.createStatement();
		statement.execute(query);
		conect.close();
	} catch (SQLException e) {
		e.printStackTrace();
	}
}
 
开发者ID:stppy,项目名称:spr,代码行数:22,代码来源:SqlUpdates.java

示例8: simpleSave

import java.sql.SQLException; //导入方法依赖的package包/类
public void simpleSave() {
	getAllTexts();
	if(tabHead.getText()!=null && !tabHead.getText().equals(""))
	{
		// pass
	}
	else {
		log.debug("can't save, no name");
		App.getMainController().addStatus("Unable to save without a name.");
		return;
	}
	try{
		Backend.getTemplateDao().saveFullTemplate(template);
		log.debug("Save successfull!");
		log.debug("template id: " + template.getID());
		App.getMainController().addStatus("Successfully saved base Template " + template.getName() + " ID: " + template.getID());
	}catch(SQLException e){
		log.error(e);
		e.printStackTrace();
	}
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:22,代码来源:TemplateTabController.java

示例9: deletePrograma

import java.sql.SQLException; //导入方法依赖的package包/类
public static boolean deletePrograma(Programa objeto){
	try {
		Connection conect=ConnectionConfiguration.conectar();
		String query = "update programa set borrado= ? ";	
		PreparedStatement update = null;
		objeto.changeBorrado();
	  	 
		query+=" where id = ? "; 
		
		update.execute(query);
	    conect.close();
	    return true;
	 } catch (SQLException e) {e.printStackTrace(); return false;}
}
 
开发者ID:stppy,项目名称:spr,代码行数:15,代码来源:SqlDelete.java

示例10: init

import java.sql.SQLException; //导入方法依赖的package包/类
public void init() {
    try (Connection c = sql.getConnection()) {
        try (PreparedStatement ps = c.prepareStatement(CREATE_TABLE)) {
            ps.execute();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
开发者ID:lucko,项目名称:NetworkAnalytics,代码行数:10,代码来源:DataManager.java

示例11: DatabaseComparator

import java.sql.SQLException; //导入方法依赖的package包/类
public DatabaseComparator(Database aDatabase, Connection aDbmsConnection) {
	database = aDatabase;
	dbmsConnection = aDbmsConnection;
	queriesForUpdate = new ArrayList<String>();
	localTablesOnDbms = new ArrayList<Table>();
	
	try {
		databaseMetadata = getDbmsConnection().getMetaData();
		tablesResultSet = databaseMetadata.getTables(null, null, null, new String[] {"TABLE"});
	} catch (SQLException e) {
		e.printStackTrace();
	}
}
 
开发者ID:tteguayco,项目名称:JITRAX,代码行数:14,代码来源:DatabaseComparator.java

示例12: main

import java.sql.SQLException; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	Connection theCon = null;
	try {
		theCon = BaseSQLExeTest.getCon(args);
		testJDBCBatchInsert(theCon);
	} catch (SQLException e) {
		e.printStackTrace();
	} finally {
		BaseSQLExeTest.closeCon(theCon);
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:12,代码来源:StandBatchInsertTest.java

示例13: selectUnidadMedida

import java.sql.SQLException; //导入方法依赖的package包/类
public static List<UnidadMedida> selectUnidadMedida() throws SQLException{
Connection conect=ConnectionConfiguration.conectar();
String query = " select * from unidad_medida ORDER BY descripcion";

Statement statement = null;
ResultSet rs=null;
List<UnidadMedida> objetos = new ArrayList<UnidadMedida>();

try {
	statement = conect.createStatement();
	rs=statement.executeQuery(query);
	while(rs.next()){
		UnidadMedida objeto = new UnidadMedida();

		objeto.setId(rs.getInt("id"));
		objeto.setNombre(rs.getString("nombre"));
		objeto.setDescripcion(rs.getString("descripcion"));
		objeto.setSigla(rs.getString("sigla"));
		objeto.setBorrado(rs.getBoolean("borrado"));

		objetos.add(objeto);
	}
}
catch (SQLException e) {e.printStackTrace();}
finally{
	if (statement != null) {statement.close();}
	if (conect != null) {conect.close();}
}
return objetos; 
}
 
开发者ID:stppy,项目名称:tcp,代码行数:31,代码来源:SqlSelects.java

示例14: initSpBox

import java.sql.SQLException; //导入方法依赖的package包/类
private void initSpBox() {
	List list = new ArrayList();
	ResultSet set = Dao.query("select * from tb_kucun where "
			+ "id in(select id from tb_spinfo where gysName='"
			+ gys.getSelectedItem() + "')");
	sp.removeAllItems();
	sp.addItem(new TbKucun());
	for (int i = 0; table != null && i < table.getRowCount(); i++) {
		TbKucun tmpInfo = (TbKucun) table.getValueAt(i, 0);
		if (tmpInfo != null && tmpInfo.getId() != null)
			list.add(tmpInfo.getId());
	}
	try {
		while (set.next()) {
			TbKucun kucun = new TbKucun();
			kucun.setId(set.getString("id").trim());
			// ���������Դ���ͬ����Ʒ����Ʒ�������оͲ��ٰ�������Ʒ
			if (list.contains(kucun.getId()))
				continue;
			kucun.setSpname(set.getString("spname").trim());
			kucun.setCd(set.getString("cd").trim());
			kucun.setJc(set.getString("jc").trim());
			kucun.setDw(set.getString("dw").trim());
			kucun.setGg(set.getString("gg").trim());
			kucun.setBz(set.getString("bz").trim());
			kucun.setDj(Double.valueOf(set.getString("dj").trim()));
			kucun.setKcsl(Integer.valueOf(set.getString("kcsl").trim()));
			sp.addItem(kucun);
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Edward7Zhang,项目名称:SuperMarketManageSystem,代码行数:34,代码来源:JinHuoTuiHuo.java

示例15: testAny

import java.sql.SQLException; //导入方法依赖的package包/类
public void testAny() {

        try {
            String ddl =
                "drop table PRICE_RELATE_USER_ORDER_V2 if exists;"
                + "create table PRICE_RELATE_USER_ORDER_V2 "
                + "(ID_ORDER_V2 BIGINT, ID_USER NUMERIC, DATE_CREATE TIMESTAMP)";
            String sql = "insert into PRICE_RELATE_USER_ORDER_V2 "
                         + "(ID_ORDER_V2, ID_USER, DATE_CREATE) " + "values "
                         + "(?, ?, ?)";
            Statement st = connection.createStatement();

            st.execute(ddl);

            PreparedStatement ps = connection.prepareStatement(sql);

            ps.setLong(1, 1);
            ps.setNull(2, Types.NUMERIC);
            ps.setTimestamp(
                3, new java.sql.Timestamp(System.currentTimeMillis()));
            ps.execute();
        } catch (SQLException e) {
            e.printStackTrace();
            System.out.println("TestSql.testAny() error: " + e.getMessage());
        }

        System.out.println("testAny complete");
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:29,代码来源:TestSql.java


注:本文中的java.sql.SQLException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。