本文整理汇总了Java中java.sql.SQLNonTransientConnectionException类的典型用法代码示例。如果您正苦于以下问题:Java SQLNonTransientConnectionException类的具体用法?Java SQLNonTransientConnectionException怎么用?Java SQLNonTransientConnectionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SQLNonTransientConnectionException类属于java.sql包,在下文中一共展示了SQLNonTransientConnectionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test11
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException("Exception 1", t1);
SQLNonTransientConnectionException ex1 =
new SQLNonTransientConnectionException("Exception 2");
SQLNonTransientConnectionException ex2 =
new SQLNonTransientConnectionException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
示例2: test12
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLNonTransientConnectionException ex =
new SQLNonTransientConnectionException("Exception 1", t1);
SQLNonTransientConnectionException ex1 =
new SQLNonTransientConnectionException("Exception 2");
SQLNonTransientConnectionException ex2 =
new SQLNonTransientConnectionException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
示例3: shto
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
private void shto(){
try {
if (!txtEmri.getText().isEmpty() && !txtVendbanimi.getText().isEmpty() && !txtMakina.getText().isEmpty()
&& !txtMbiemri.getText().isEmpty()) {
String em = txtEmri.getText().substring(0, 1).toUpperCase() + txtEmri.getText().substring(1, txtEmri.getText().length()).toLowerCase();
String mb = txtMbiemri.getText().substring(0, 1).toUpperCase() + txtMbiemri.getText().substring(1, txtMbiemri.getText().length()).toLowerCase();
String sql = "insert into Konsumatori (emri, mbiemri, makina, komuna, pershkrimi) values ('" + em + "', " +
"'" + mb + "', '" + txtMakina.getText() + "', '" + txtVendbanimi.getText() + "', " +
"'" + txtDesc.getText() + "')";
Connection conn = DriverManager.getConnection(CON_STR, "test", "test");
Statement stmt = conn.createStatement();
stmt.execute(sql);
conn.close();
new Mesazhi("Sukses", "Sukses", "Konsumatori " + txtEmri.getText().toUpperCase() + " " +
txtMbiemri.getText().toUpperCase() + " u shtua me sukese");
}else new Mesazhi("Info", "", "Fushat duhet te plotesohen per te vazhduar.");
}catch (SQLNonTransientConnectionException fu){}
catch (Exception ex){
ex.printStackTrace();
}
}
示例4: shtoPunetoreMethod
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
private void shtoPunetoreMethod(){
try {
if (!emri.getText().isEmpty() && !mbiemri.getText().isEmpty() && !komuna.getText().isEmpty() && !pjesa.getText().isEmpty() &&
!paga.getText().isEmpty() && !data.getEditor().getText().isEmpty() && !pw.getText().isEmpty()) {
String em = emri.getText().substring(0, 1).toUpperCase() + emri.getText().substring(1, emri.getText().length()).toLowerCase();
String mb = mbiemri.getText().substring(0, 1).toUpperCase() + mbiemri.getText().substring(1, mbiemri.getText().length()).toLowerCase();
String sql = "insert into Punetoret (emri, mbiemri, komuna, pozita, paga, regjistrimi) values ('" +
em + "', '" + mb + "', '" + komuna.getText() + "', '" + pjesa.getText() + "', " +
Float.parseFloat(paga.getText()) + ", DATE '" + data.getValue() + "')";
String adminSql = "insert into Admin (emri, fjalekalimi, lloji) values " +
"('" + emri.getText().toLowerCase() + mbiemri.getText().toLowerCase() + "', '" + pw.getText() + "', 0)";
Connection conn = DriverManager.getConnection(CON_STR, "test", "test");
Statement stmt = conn.createStatement();
Statement AdminStmt = conn.createStatement();
stmt.execute(sql);
AdminStmt.execute(adminSql);
conn.close();
new Mesazhi("Sukses", em + " " + mb, "Punetori u shtua me sukses me daten " + data.getEditor().getText());
stage.close();
}else new Mesazhi("Info", "", "Fushat duhet te plotesohen para se te vazhdoni");
}catch (SQLNonTransientConnectionException fu){}
catch (NumberFormatException nfw){new Mesazhi("Info", "Gabim", "Fusha qmimi duhet te permbaj vetem numra.");}
catch (Exception ex){ex.printStackTrace();}
}
示例5: rregullo
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
private void rregullo(int id){
try {
if (!user.getText().isEmpty() && !pw.getText().isEmpty()) {
String sql = "update Admin set emri = '" + user.getText() + "', fjalekalimi = '" + pw.getText() +
"' where id = " + id;
System.out.println("ID: " + id);
Connection conn = DriverManager.getConnection(CON_STR, "test", "test");
Statement stmt = conn.createStatement();
stmt.execute(sql);
conn.close();
new Mesazhi("Sukses", "", "Te dhenat u ruajten me sukses. Ju lutem restartoni programin.");
stage.close();
}
else new Mesazhi("Gabim", "", "Fushat duhet te plotesohen para se te vazhdoni");
}catch (SQLNonTransientConnectionException fu){}
catch (NullPointerException npe){new Mesazhi("Info", "Gabim", "Fusha qmimi duhet te permbaj vetem numra.");}
catch (Exception ex){ex.printStackTrace();}
}
示例6: Debug_tests_43222
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
public void Debug_tests_43222() throws SQLException {
final Connection conn = getConnection();
final Statement stmt = conn.createStatement();
conn.setTransactionIsolation(getIsolationLevel());
stmt.execute("create table warehouse ( w_id integer not null,"
+ " w_ytd decimal(12,2),"
+ " w_tax decimal(4,4),"
+ " w_name varchar(10)) replicate"+getSuffix());
stmt.execute("alter table warehouse add constraint pk_warehouse "
+ "primary key (w_id)");
stmt.execute("insert into warehouse values(1, 0.0, 0.0, 'name1'), "
+ "(2, 0.2, 0.0, 'name2')");
conn.commit();
int i = stmt.executeUpdate("UPDATE warehouse SET w_ytd = w_ytd + 4998.73 "
+ "WHERE w_id = 1");
System.out.println(i);
SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException();
System.out.println("ex.getSQLState returned: " + ex.getSQLState());
}
示例7: handleConnectFailure
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
public static void handleConnectFailure(SQLNonTransientConnectionException e, String databaseUrl) {
logger.trace("handleConnectFailure( SQLNonTransientConnectionException )");
boolean suppress = false;
try {
suppress = isDbNotFoundException(e);
} catch (AdeInternalException i) {
logger.error("Unable to determine sqlstate", i);
}
if (suppress) {
logger.info("Suppress connection failure (nonexistent db), url: " + databaseUrl);
} else {
handleConnectFailure(e);
}
}
示例8: getConnection
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
public CassandraConnection getConnection(String user, String password) throws SQLException
{
Properties props = new Properties();
this.user = user;
this.password = password;
if (this.serverName!=null) props.setProperty(TAG_SERVER_NAME, this.serverName);
else throw new SQLNonTransientConnectionException(HOST_REQUIRED);
props.setProperty(TAG_PORT_NUMBER, ""+this.portNumber);
if (this.databaseName!=null) props.setProperty(TAG_DATABASE_NAME, this.databaseName);
if (user!=null) props.setProperty(TAG_USER, user);
if (password!=null) props.setProperty(TAG_PASSWORD, password);
if (this.version != null) props.setProperty(TAG_CQL_VERSION, version);
if (this.consistency != null) props.setProperty(TAG_CONSISTENCY_LEVEL, consistency);
String url = PROTOCOL+createSubName(props);
return (CassandraConnection) DriverManager.getConnection(url, props);
}
示例9: test_Constructor_LStringLString
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
/**
* @test java.sql.SQLNonTransientConnectionException(String, String)
*/
public void test_Constructor_LStringLString() {
SQLNonTransientConnectionException sQLNonTransientConnectionException = new SQLNonTransientConnectionException(
"MYTESTSTRING1", "MYTESTSTRING2");
assertNotNull(sQLNonTransientConnectionException);
assertEquals(
"The SQLState of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING2", sQLNonTransientConnectionException
.getSQLState());
assertEquals(
"The reason of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING1", sQLNonTransientConnectionException
.getMessage());
assertEquals(
"The error code of SQLNonTransientConnectionException should be 0",
sQLNonTransientConnectionException.getErrorCode(), 0);
}
示例10: test_Constructor_LStringLString_2
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
/**
* @test java.sql.SQLNonTransientConnectionException(String, String)
*/
public void test_Constructor_LStringLString_2() {
SQLNonTransientConnectionException sQLNonTransientConnectionException = new SQLNonTransientConnectionException(
null, "MYTESTSTRING");
assertNotNull(sQLNonTransientConnectionException);
assertEquals(
"The SQLState of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING", sQLNonTransientConnectionException
.getSQLState());
assertNull(
"The reason of SQLNonTransientConnectionException should be null",
sQLNonTransientConnectionException.getMessage());
assertEquals(
"The error code of SQLNonTransientConnectionException should be 0",
sQLNonTransientConnectionException.getErrorCode(), 0);
}
示例11: test_Constructor_LStringLStringI
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
/**
* @test java.sql.SQLNonTransientConnectionException(String, String, int)
*/
public void test_Constructor_LStringLStringI() {
SQLNonTransientConnectionException sQLNonTransientConnectionException = new SQLNonTransientConnectionException(
"MYTESTSTRING1", "MYTESTSTRING2", 1);
assertNotNull(sQLNonTransientConnectionException);
assertEquals(
"The SQLState of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING2", sQLNonTransientConnectionException
.getSQLState());
assertEquals(
"The reason of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING1", sQLNonTransientConnectionException
.getMessage());
assertEquals(
"The error code of SQLNonTransientConnectionException should be 1",
sQLNonTransientConnectionException.getErrorCode(), 1);
}
示例12: test_Constructor_LStringLStringI_1
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
/**
* @test java.sql.SQLNonTransientConnectionException(String, String, int)
*/
public void test_Constructor_LStringLStringI_1() {
SQLNonTransientConnectionException sQLNonTransientConnectionException = new SQLNonTransientConnectionException(
"MYTESTSTRING1", "MYTESTSTRING2", 0);
assertNotNull(sQLNonTransientConnectionException);
assertEquals(
"The SQLState of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING2", sQLNonTransientConnectionException
.getSQLState());
assertEquals(
"The reason of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING1", sQLNonTransientConnectionException
.getMessage());
assertEquals(
"The error code of SQLNonTransientConnectionException should be 0",
sQLNonTransientConnectionException.getErrorCode(), 0);
}
示例13: test_Constructor_LStringLStringI_2
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
/**
* @test java.sql.SQLNonTransientConnectionException(String, String, int)
*/
public void test_Constructor_LStringLStringI_2() {
SQLNonTransientConnectionException sQLNonTransientConnectionException = new SQLNonTransientConnectionException(
"MYTESTSTRING1", "MYTESTSTRING2", -1);
assertNotNull(sQLNonTransientConnectionException);
assertEquals(
"The SQLState of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING2", sQLNonTransientConnectionException
.getSQLState());
assertEquals(
"The reason of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING1", sQLNonTransientConnectionException
.getMessage());
assertEquals(
"The error code of SQLNonTransientConnectionException should be -1",
sQLNonTransientConnectionException.getErrorCode(), -1);
}
示例14: test_Constructor_LStringLStringI_6
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
/**
* @test java.sql.SQLNonTransientConnectionException(String, String, int)
*/
public void test_Constructor_LStringLStringI_6() {
SQLNonTransientConnectionException sQLNonTransientConnectionException = new SQLNonTransientConnectionException(
null, "MYTESTSTRING", 1);
assertNotNull(sQLNonTransientConnectionException);
assertEquals(
"The SQLState of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING", sQLNonTransientConnectionException
.getSQLState());
assertNull(
"The reason of SQLNonTransientConnectionException should be null",
sQLNonTransientConnectionException.getMessage());
assertEquals(
"The error code of SQLNonTransientConnectionException should be 1",
sQLNonTransientConnectionException.getErrorCode(), 1);
}
示例15: test_Constructor_LStringLStringI_7
import java.sql.SQLNonTransientConnectionException; //导入依赖的package包/类
/**
* @test java.sql.SQLNonTransientConnectionException(String, String, int)
*/
public void test_Constructor_LStringLStringI_7() {
SQLNonTransientConnectionException sQLNonTransientConnectionException = new SQLNonTransientConnectionException(
null, "MYTESTSTRING", 0);
assertNotNull(sQLNonTransientConnectionException);
assertEquals(
"The SQLState of SQLNonTransientConnectionException set and get should be equivalent",
"MYTESTSTRING", sQLNonTransientConnectionException
.getSQLState());
assertNull(
"The reason of SQLNonTransientConnectionException should be null",
sQLNonTransientConnectionException.getMessage());
assertEquals(
"The error code of SQLNonTransientConnectionException should be 0",
sQLNonTransientConnectionException.getErrorCode(), 0);
}