List of usage examples for java.sql SQLException toString
public String toString()
From source file:org.apache.sqoop.manager.sqlserver.SQLServerManagerManualTest.java
@After public void tearDown() { try {/*from ww w .j a v a 2 s . c o m*/ MSSQLTestUtils utils = new MSSQLTestUtils(); utils.dropTableIfExists("TPCH1M_LINEITEM"); manager.close(); } catch (SQLException sqlE) { LOG.error("Got SQLException: " + sqlE.toString()); fail("Got SQLException: " + sqlE.toString()); } }
From source file:com.cloudera.sqoop.manager.PostgresqlTest.java
@Before public void setUp() { super.setUp(); LOG.debug("Setting up another postgresql test: " + CONNECT_STRING); SqoopOptions options = new SqoopOptions(CONNECT_STRING, TABLE_NAME); options.setUsername(DATABASE_USER);//from www . ja v a 2 s . c o m ConnManager manager = null; Connection connection = null; Statement st = null; try { manager = new PostgresqlManager(options); connection = manager.getConnection(); connection.setAutoCommit(false); st = connection.createStatement(); // create the database table and populate it with data. try { // Try to remove the table first. DROP TABLE IF EXISTS didn't // get added until pg 8.3, so we just use "DROP TABLE" and ignore // any exception here if one occurs. st.executeUpdate("DROP TABLE " + TABLE_NAME); } catch (SQLException e) { LOG.info("Couldn't drop table " + TABLE_NAME + " (ok)"); LOG.info(e.toString()); // Now we need to reset the transaction. connection.rollback(); } st.executeUpdate("CREATE TABLE " + TABLE_NAME + " (" + "id INT NOT NULL PRIMARY KEY, " + "name VARCHAR(24) NOT NULL, " + "start_date DATE, " + "salary FLOAT, " + "dept VARCHAR(32))"); st.executeUpdate( "INSERT INTO " + TABLE_NAME + " VALUES(" + "1,'Aaron','2009-05-14',1000000.00,'engineering')"); st.executeUpdate("INSERT INTO " + TABLE_NAME + " VALUES(" + "2,'Bob','2009-04-20',400.00,'sales')"); st.executeUpdate("INSERT INTO " + TABLE_NAME + " VALUES(" + "3,'Fred','2009-01-23',15.00,'marketing')"); connection.commit(); } catch (SQLException sqlE) { LOG.error("Encountered SQL Exception: " + sqlE); sqlE.printStackTrace(); fail("SQLException when running test setUp(): " + sqlE); } finally { try { if (null != st) { st.close(); } if (null != manager) { manager.close(); } } catch (SQLException sqlE) { LOG.warn("Got SQLException when closing connection: " + sqlE); } } LOG.debug("setUp complete."); }
From source file:itesm.mx.golpedecalor.MonitoringActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_monitoring); alerta = false;//from ww w .j a v a 2 s. c o m dbo = new DataBaseOperations(getApplicationContext()); groupId = getIntent().getLongExtra("id", 0); // Referencias a objetos de interfacae tablaTL = (TableLayout) findViewById(R.id.tablaTL); nombreTV = (TextView) findViewById(R.id.nombreTV); causaTV = (TextView) findViewById(R.id.causaTV); parametroTV = (TextView) findViewById(R.id.parametroTV); switcherVS = (ViewSwitcher) findViewById(R.id.switcherVS); mp = MediaPlayer.create(this, R.raw.alert); recomendacionesTV = (TextView) findViewById(R.id.recomendacionesTV); // Inicializacin rc = new ArrayList<TextView>(); temp = new ArrayList<TextView>(); rad = new ArrayList<TextView>(); try { dbo.open(); } catch (SQLException ex) { Log.e("", ex.toString()); } grupo = dbo.getGroup(groupId); grupo.setIntegrantes(dbo.getAllUsersFromGroup(grupo)); monitoreoHelper = new Monitoreo(grupo, this); for (Usuario u : grupo.getIntegrantes()) { TableRow tr = new TableRow(this); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.FILL_PARENT)); TextView tvAux = new TextView(this); tvAux.setText(u.getNombre() + " " + u.getApellidos()); tvAux.setLayoutParams(new TableRow.LayoutParams(400, TableRow.LayoutParams.WRAP_CONTENT)); TextView rcAux = new TextView(this); rcAux.setText("5"); rcAux.setLayoutParams(new TableRow.LayoutParams(200, TableRow.LayoutParams.WRAP_CONTENT)); TextView tempAux = new TextView(this); tempAux.setText("9"); tempAux.setLayoutParams(new TableRow.LayoutParams(200, TableRow.LayoutParams.WRAP_CONTENT)); TextView radAux = new TextView(this); radAux.setText("10"); radAux.setLayoutParams(new TableRow.LayoutParams(100, TableRow.LayoutParams.WRAP_CONTENT)); rc.add(rcAux); temp.add(tempAux); rad.add(radAux); tr.addView(tvAux); tr.addView(rcAux); tr.addView(tempAux); tr.addView(radAux); tr.setBackgroundResource(R.drawable.tabla); // Asigna recurso de drawable a la row nueva tablaTL.addView(tr); } monitoreoHelper.empezarMonitoreo(); notificationIntent = new Intent(getApplicationContext(), NotificationActivity.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: monitoreoHelper.terminarAlerta(); break; case DialogInterface.BUTTON_NEGATIVE: //No button clicked break; } } }; }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
@Test public void ResultSetMetadata() { try {//from w w w . j a va 2 s . c o m this.logger.debug(BQForwardOnlyResultSetFunctionTest.Result.getMetaData().getSchemaName(1)); this.logger.debug(BQForwardOnlyResultSetFunctionTest.Result.getMetaData().getScale(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); } Assert.assertTrue(true); }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
@Test public void TestResultSetgetFloat() { try {/*from w w w . j a va2s .c o m*/ Assert.assertTrue(Result.next()); Assert.assertEquals(new Float(42), BQForwardOnlyResultSetFunctionTest.Result.getFloat(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
@Test public void TestResultSetgetInteger() { try {/*w ww . j a v a 2 s . c o m*/ Assert.assertTrue(Result.next()); Assert.assertEquals(42, BQForwardOnlyResultSetFunctionTest.Result.getInt(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
@Test public void TestResultSetgetString() { try {//from ww w. ja v a 2 s.co m Assert.assertTrue(Result.next()); Assert.assertEquals("you", BQForwardOnlyResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
@Test public void TestResultSetFirst() { try {/*www .ja v a 2 s . c o m*/ // Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.first()); Result.next(); Assert.assertTrue(BQForwardOnlyResultSetFunctionTest.Result.isFirst()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
@Test public void TestResultSetgetBoolean() { try {/*from w w w . j a va 2 s. c o m*/ Assert.assertTrue(Result.next()); Assert.assertEquals(Boolean.parseBoolean("42"), BQForwardOnlyResultSetFunctionTest.Result.getBoolean(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } }
From source file:BQJDBC.QueryResultTest.BQForwardOnlyResultSetFunctionTest.java
public void QueryLoad() { final String sql = "SELECT TOP(word,10) AS word, COUNT(*) as count FROM publicdata:samples.shakespeare"; this.logger.info("Test number: 01"); this.logger.info("Running query:" + sql); try {/*from w ww. ja v a 2s .c om*/ //Statement stmt = BQResultSetFunctionTest.con.createStatement(); Statement stmt = BQForwardOnlyResultSetFunctionTest.con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); stmt.setQueryTimeout(500); BQForwardOnlyResultSetFunctionTest.Result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } Assert.assertNotNull(BQForwardOnlyResultSetFunctionTest.Result); }