Atualizar no SQL

PostgreSQL no FreeBSD com banco de dados em pt_BR

2020.03.03 23:17 shastybsd PostgreSQL no FreeBSD com banco de dados em pt_BR

Ambiente:
FreeBSD 12.1 AMD64 PostgreSQL 10.11 

Atualização do pkg e instalação do PostgreSQL
 # pkg update -f # pkg install postgresql10-server 

Parâmetros do PostgreSQL pós instalação
Acertar a classe do login do usuário postgres para linguagem em pt\_BR Editar /etc/login.conf e inseri as linhas abaixo: postgres:\ :lang=pt_BR.UTF-8:\ :setenv=LC_COLLATE=C:\ :tc=default: Atualizar a base de dados com o comando: # cap_mkdb /etc/login.conf Editar o /etc/rc.conf e inserir os seguintes parametros para o PostgreSQL postgresql_enable="YES" postgresql_class="postgres" postgresql_initdb_flags="--encoding=UTF8 --lc-collate=pt_BR.UTF-8 --lc-ctype=pt_BR.UTF-8" 

  1. Inicialização do banco de dados

 # /uslocal/etc/rc.d/postgresql initdb 

  1. Configuração do PostgreSQL
    Alternar para o usuário postgres
    # su – postgres 
    A base de dados fica em /vadb/postgres/data10
    $ cd /vadb/postgres/data10/ 
    Editar o arquivo pg_hba.conf para liberar o acesso para a rede local. Neste caso a rede local é 192.168.101.0/24, ajustar para a rede utilizada localizando no arquivo a seguinte linha:

    IPv4 local connections:

    host all all 127.0.0.1/32 trust
    Após, insira logo abaixo a linha:
    host all all 192.168.101.0/24 trust
    Editar o arquivo postgresql.conf e localizar a linha:

    listen_addresses = ‘localhost’

    Retirar o comentário e alterar para:
    listen_addresses = ‘*’
    Após esses procedimentos, será necessário iniciar o banco de dados. Será necessário retornar para o usuário root.
    # /uslocal/etc/rc.d/postgresql start 
submitted by shastybsd to u/shastybsd [link] [comments]


2014.03.29 03:52 spercalifragilistic First time that i run the app crash, second runs fine

I creating a quiz game, but every time that I need reinstal it, the first time i execute him, give me a exception.
My Code public final Context context = this; public static MediaPlayer media;
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Swarm.setAllowGuests(true); Swarm.init(this, 10462, "76388bd5ec3a579790ff9f05b14c7f9e"); media = MediaPlayer.create(this, R.raw.intro); } public void newGame(View view){ Intent intent = new Intent(ShowdoMilhao.this, ControlGaming.class ); startActivity(intent); } 
My date context
public class ContextoDados extends SQLiteOpenHelper { private static final String NOME_BD = "DadosShowMilhao"; private static final int VERSAO_BD = 17; private static final String LOG_TAG = "DadosShowMilhao"; private final Context contexto; public ContextoDados(Context context) { super(context, NOME_BD, null, VERSAO_BD); this.contexto = context; } @Override public void onCreate(SQLiteDatabase db) { String[] sql = contexto.getString(R.string.ContextoDados_onCreate).split("\n"); String[] sql2 = contexto.getString(R.string.ContextoDados_data).split("\n"); db.beginTransaction(); try { ExecutarComandosSQLVetor(db, sql); db.setTransactionSuccessful(); } catch (SQLException e) { Log.e("Erro ao criar as tabelas.", e.toString()); } finally { db.endTransaction(); } try { ExecutarComandosSQLVetor(db, sql2); db.setTransactionSuccessful(); } catch (SQLException e) { Log.e("Erro ao popular as tabelas", e.toString()); } finally { db.endTransaction(); } } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { Log.w(LOG_TAG, "Atualizando a base de dados da versão " + oldVersion + " para " + newVersion + ", que destruirão todos os dados antigos"); String[] sql = contexto.getString(R.string.ContextoDados_onUpgrade).split("\n"); db.beginTransaction(); try { ExecutarComandosSQLVetor(db, sql); db.setTransactionSuccessful(); } catch (SQLException e) { throw e; } finally { db.endTransaction(); } onCreate(db); } public void ExecutarComandosSQLVetor(SQLiteDatabase db, String[] sql) { for( String s : sql ) if (s.trim().length()>0) db.execSQL(s); } public Cursor RetornarDadosComandosSQL(String sql){ SQLiteDatabase db = getWritableDatabase(); Cursor cursor = db.rawQuery(sql, new String[]{}); return cursor; } public void DroparBase() { SQLiteDatabase db = getWritableDatabase(); String[] sql = contexto.getString(R.string.ContextoDados_onUpgrade).split("\n"); db.beginTransaction(); try { ExecutarComandosSQLVetor(db, sql); db.setTransactionSuccessful(); } catch (SQLException e) { Log.e("Erro ao atualizar as tabelas e testar os dados", e.toString()); throw e; } finally { db.endTransaction(); } } public Cursor RetornarDados(SQLiteDatabase db, String Tabelas, String[] Colunas, String Argumentos, String[] Clausulas, int OrdemPosition){ Cursor cursor = db.query(Tabelas, Colunas, Argumentos, Clausulas, null, null, Integer.toString(OrdemPosition) ); return cursor; } public Cursor RetornarDados2(String Tabelas, String[] Colunas, String Argumentos, String[] Clausulas, int OrdemPosition){ SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.query(Tabelas, Colunas, Argumentos, Clausulas, null, null, Integer.toString(OrdemPosition) ); return cursor; } public void Insert(SQLiteDatabase db, String Table, ContentValues Values){ try { db.insert(Table, null, Values); } finally { db.close(); } } public void Delete(SQLiteDatabase db, String Tabelas, String Argumentos, String[] Clausulas){ db.delete(Tabelas, Argumentos, Clausulas); } public void Update(SQLiteDatabase db, String Tabelas, ContentValues Values, String Argumentos, String[] Clausulas ){ db.update(Tabelas, Values, Argumentos, Clausulas); } public void exportDataBase() throws IOException{ String inFileName = this.getReadableDatabase().getPath(); InputStream myInput = new BufferedInputStream(new FileInputStream(inFileName)); String outFileName = "/storage/extSdCard/Download/" + NOME_BD; OutputStream myOutput = new FileOutputStream(outFileName); byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } 
}
My logcat
03-28 23:49:35.437: E/AndroidRuntime(5237): FATAL EXCEPTION: main 03-28 23:49:35.437: E/AndroidRuntime(5237): Process: com.example.showdomilhao, PID: 5237 03-28 23:49:35.437: E/AndroidRuntime(5237): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.showdomilhao/com.example.showdomilhao.ControlGaming}: java.lang.IllegalStateException: Cannot perform this operation because there is no current transaction. 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.app.ActivityThread.access$800(ActivityThread.java:139) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.os.Handler.dispatchMessage(Handler.java:102) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.os.Looper.loop(Looper.java:136) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.app.ActivityThread.main(ActivityThread.java:5102) 03-28 23:49:35.437: E/AndroidRuntime(5237): at java.lang.reflect.Method.invokeNative(Native Method) 03-28 23:49:35.437: E/AndroidRuntime(5237): at java.lang.reflect.Method.invoke(Method.java:515) 03-28 23:49:35.437: E/AndroidRuntime(5237): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 03-28 23:49:35.437: E/AndroidRuntime(5237): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 03-28 23:49:35.437: E/AndroidRuntime(5237): at dalvik.system.NativeStart.main(Native Method) 03-28 23:49:35.437: E/AndroidRuntime(5237): Caused by: java.lang.IllegalStateException: Cannot perform this operation because there is no current transaction. 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.database.sqlite.SQLiteSession.throwIfNoTransaction(SQLiteSession.java:915) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:398) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:522) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:263) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:188) 03-28 23:49:35.437: E/AndroidRuntime(5237): at com.example.showdomilhao.ControlGaming.AtualizarCondicao(ControlGaming.java:136) 03-28 23:49:35.437: E/AndroidRuntime(5237): at com.example.showdomilhao.ControlGaming.Rodada(ControlGaming.java:160) 03-28 23:49:35.437: E/AndroidRuntime(5237): at com.example.showdomilhao.ControlGaming.onCreate(ControlGaming.java:121) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.app.Activity.performCreate(Activity.java:5248) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110) 03-28 23:49:35.437: E/AndroidRuntime(5237): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2173) 
submitted by spercalifragilistic to androiddev [link] [comments]