Banco de dados rodando na memória – Java
Banco de dados relacional rodando na memória
Abaixo vou mostrar como utilizar um banco de dados 100% em memória, sem a necessidade de nenhuma instalação ou configuração. Essa abordagem pode ser muito útil para gravar dados temporários e utilizar todos os benefícios de um banco relacional, como restrições de integridade, sequences, etc.
O banco de dados é o H2. Ele é muito utilizado como banco local em aplicações stand alone, com persistência no disco e dados não voláteis, mas também pode ser usado apenas para gravar dados temporários.
Estou desenvolvendo funcionalidades para uma aplicação que importa dados e sempre, antes da execução, eu tinha que limpar o banco – e que mais pessoas acessavam. Então passei a utilizar o H2 com a execução um script DDL antes do processamento.
[java]
package h2;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.Test;
public class H2Test {
@Test
public void testDatabaseH2() throws SQLException, IOException {
Connection connection = DriverManager.getConnection("jdbc:h2:cnis");
Statement s = connection.createStatement();
try {
for (String linha:getConteudoArquivo("D:\\Temp\\drop_tables.txt")
.toString().split(System.lineSeparator())) {
if (!linha.isEmpty()) {
s.execute(linha);
}
}
} catch (SQLException sqle) {
sqle.printStackTrace();
}
try {
s.execute(getConteudoArquivo("D:\\Temp\\create_tables.txt").toString());
} catch (SQLException sqle) {
sqle.printStackTrace();
}
s.close();
connection.close();
}
private StringBuilder getConteudoArquivo(String caminho) throws IOException {
StringBuilder retorno = new StringBuilder();
BufferedReader buf = new BufferedReader(
new InputStreamReader(new FileInputStream(caminho)));
String linha = null;
while ((linha=buf.readLine())!=null) {
retorno.append(linha + System.lineSeparator());
}
buf.close();
return retorno;
}
}
[/java]
Boa sorte.
143 Replies to “Banco de dados rodando na memória – Java”
One platform you should use is LocalBitcoins.
Cryptocurrencies ɑre excellent limited tߋ criminals.
https://buysildenshop.com/ – viagra phizer
https://buylasixshop.com/ – Lasix
Plaquenil
http://buyneurontine.com/ – gabapentin abuse
Viagra C’Est Plus Fort Toi
Cialis
Cialis Super Active 100mg
Stromectol
Amoxicillin While Pregnant
Buy Generic Propecia 20 Mg cialis 5mg best price
cialis without a prescription
Читайте отзывы о lex casino и активируйте бонусы по ссылке казино лекс
viagra es
http://www.alevitrasp.com Loammasnotte Sexual behaviours were seen as internal and external events in reaction to stimuli evaluated culturally as sexual although in this case also evaluated as not being the suitable ones for a person of that gender by a sector of society or even by the same individual.
Plaquenil Nesxrr
Amazing facts. Thanks!
creative college essay papers writing service write my paragraph for me
Esser W. Dr. Rechtsanwalt
buy macrobid 50 mg macrobid 100 mg online macrobid 50mg online
erythromycin nz cheap erythromycin 500mg erythromycin online
imuran 50 mg coupon where to buy imuran buy imuran 25 mg
creditsenligne.org/1000-euros
lasix 100 mg online lasix cost lasix 40 mg pills
Sprint
Praxis fur Physiotherapie und Physio Fit Helene Alt
ceftin 250mg purchase ceftin no prescription ceftin without a doctor prescription
lan 100000
dramamine generic dramamine over the counter buy dramamine 50 mg
Zweckverband Abfallwirtschaft Saale-Orla (ZASO)
ciprofloxacin united states ciprofloxacin 500 mg costwhere can i buy ciprofloxacin ciprofloxacin for sale
lana 20000 kr direkt
toprol tablet toprol 50 mg without prescription toprol 25mg united states
http://www.laanidanmark.com/laan-35000-kr
crestor 5 mg canada crestor without a prescription crestor 20 mg prices
Friseure Neulu?heim
desmopressin cost cost of desmopressin mcg desmopressin mcg tablets
dapsone caps cost where to buy dapsone caps dapsone 1000caps canada
lan 10000 kroner
cardizem 60 mg tablets where to buy cardizem 30 mg cardizem 60 mg tablets
Glaserei Neufahrn bei Freising
tamoxifen 10mg uk tamoxifen 20mg without a doctor prescription tamoxifen 10 mg without a prescription
lana 6000
ddavp 0.1 mg generic https://ddavp24.com/# – ddavp united kingdom ddavp 10mcg otc
Berufliches Schulzentrum August Forster
how to purchase anastrozole anastrozole canada anastrozole cheap
finasteride 1mg purchase cheap finasteride finasteride 1 mg prices
Praxis Dr. med. dent. Manuel Wolf
zofran online pharmacy zofran 4 mg prices zofran online pharmacy
pujcka 5000 Kc
meclizine 25mg coupon meclizine online meclizine pills
http://hnoarzt.com.de/kamen
order propranolol propranolol 20mg purchase cheapest propranolol
lainaa 35000e
buy geodon 80mg cheap geodon buy geodon 80mg
Immobilienunternehmen Bonnigheim
zocor united states order zocor zocor without prescription
celecoxib tablets celecoxib 100mg for sale cheapest celecoxib
cefuroxime cheap cefuroxime 500 mg over the counter how to buy cefuroxime
leflunomide cheap leflunomide 20 mg price leflunomide cheap
guenstigekreditevergleich.org/kredit-40000-euro-zinsen
robaxin 500mg cost where can i buy robaxin 500 mg robaxin price
Pathophysiologie des Asthmas
thorazine 50mg usa thorazine online thorazine cheap
digoxinmg pharmacy digoxin 0.25 mg uk digoxinmg united states
buy diamox cheapest diamox 250mg diamox tablet
sumatriptan medication sumatriptan price sumatriptan over the counter
gemfibrozil generic gemfibrozil pills where can i buy gemfibrozil
cefuroxime no prescription cefuroxime over the counter cheapest cefuroxime
carolina hautpflege
loperamide canada loperamide 2mg online loperamide over the counter
sumatriptan for sale sumatriptan 25mg united kingdom sumatriptan cheap
buy pyridium order pyridium pyridium no prescription
aldactone united kingdom aldactone 25 mg without prescription aldactone 100mg united kingdom
cefuroxime no prescription cost of cefuroxime 125mg where can i buy cefuroxime
buy pulmicort 100 mcg pulmicort australia pulmicort tablets
where can i buy periactin periactin without a prescription periactin pills
allopurinol 300mg united states allopurinol 300 mg no prescription how to purchase allopurinol
gastro Salute,llc
how to purchase ditropan 2,5 mg ditropan 5 mg online pharmacy ditropan australia
celebrex 200 mg prices celebrex tablets celebrex otc
flonase nasal spray 50mcg without a prescription flonase nasal spray 50mcg price flonase nasal spray tablet
biaxin 500 mg without prescription biaxin 250 mg without a doctor prescription biaxin 500 mg usa
können hunde asthma haben
prilosec online pharmacy prilosec nz prilosec 10mg cheap
where can i buy ditropan 5mg ditropan 5mg pills ditropan tablet
organes du systГЁme cardiovasculaire
celebrex usa celebrex cost celebrex pharmacy
diurГ©ticos ahorradores de potasio
mestinon pills mestinon 60mg no prescription mestinon 60mg pills
propecia 5mg online propecia coupon propecia 5mg united states
buy celebrex 200mg how to purchase celebrex 200 mg celebrex usa
cheapest tamoxifen cheapest tamoxifen 10mg tamoxifen united kingdom
cefuroxime without prescription cefuroxime 125 mg purchase cefuroxime generic
periactin 4mg prices periactin tablet cheap periactin 4 mg
vantin 200mg coupon vantin 200 mg nz vantin united states
verapamil 40 mg pharmacy verapamil 40mg tablet verapamil pills
exemplos de diurГ©ticos tiazГdicos
actos nz actos 15mg without prescription actos 15 mg united states
ciprofloxacin tablet where can i buy ciprofloxacin ciprofloxacin usa
gotas para los ojos con sulfa
verapamil without prescription verapamil uk verapamil 40mg without prescription
lopid 300mg pills order lopid lopid 300mg nz
imuran without a prescription cost of imuran cost of imuran 50 mg
ditropan 2,5 mg united kingdom cheapest ditropan ditropan purchase
ГҐksjuka medicin
pioglitazone medication pioglitazone 30 mg online pharmacy pioglitazone australia
жњЂй«гЃ®йЃїе¦Љи–¬
kolesterol
order warfarin warfarin without a doctor prescription warfarin prices
kardiovaskulær sykdom definisjon
biskjoldkörtelhormoner
zdravГ Еѕen v lexingtonu
avapro 300 mg purchase cheap avapro 300mg avapro medication
beste diuretica
how to buy cardizem 30 mg how to purchase cardizem 180mg cardizem 180 mg without a prescription
najlepsza piguЕ‚ka antykoncepcyjna
citalopram online citalopram 10mg pharmacy citalopram no prescription
Englewood Frauengesundheit
meclizine no prescription meclizine price meclizine purchase
clotrimazole canada clotrimazole generic clotrimazole tablets
hvor mye kolesterol i et egg
flomax usa flomax nz flomax australia
stipendio del chirurgo cardiovascolare
spiriva 9 mcg coupon spiriva 9 mcg online pharmacy where to buy spiriva
amaryl 4mg canada amaryl 2 mg coupon amaryl pharmacy
catapres 100 mcg purchase catapres without a prescription catapres 100 mcg coupon
fexofenadine canada fexofenadine for sale fexofenadine over the counter
quГ© ВїQuГ© son los diurГ©ticos ahorradores de potasio? ВїPor quГ© los diurГ©ticos ahorradores de potasio? ConversiГіn de diurГ©ticos. Ejemplos de diurГ©ticos tiazГdicos. Ejemplos de diurГ©ticos tiazГdicos. los alimentos son diurГ©ticos
singulair usa cheapest singulair singulair without a prescription
spiriva 9mcg otc spiriva 9mcg canada spiriva over the counter
cardizem 90 mg united states cardizem 60 mg pharmacy cost of cardizem
trazodone no prescription trazodone online pharmacy trazodone online
cefuroxime cheap cefuroxime price order cefuroxime
imitrex united kingdom imitrex for sale imitrex 25 mg medication
ceclor for sale ceclor generic ceclor 500mg pills
where to buy clomid clomid tablet clomid australia
lopid pills buy lopid 300 mg lopid 300 mg without prescription
aricept otc aricept 5mg without prescription aricept purchase
levaquin 750mg for sale levaquin 250 mg without prescription levaquin united states
Zyrtec-Allergie
isosorbide otc isosorbide pills buy isosorbide
clozapine australia how to buy clozapine clozapine medication