SegFault with HibernateD
Venkat
venkatram.akkineni at gmail.com
Fri Jan 12 05:24:52 UTC 2018
I get a SegFault with the main method below which uses HibernateD
. The second main method which uses ddbc just works fine. What is
wrong with the first main method ? I have attached the error at
the bottom although I don't think it says much.
This method uses HibernateD
int main() {
// setup DB connection
string url = MySQLDriver.generateUrl("localhost", 3306, "test");
string[string] params = MySQLDriver.setUserAndPassword("test",
"test");
DataSource ds = new ConnectionPoolDataSourceImpl(new
MySQLDriver(), url, params);
// create metadata from annotations
EntityMetaData schema = new SchemaInfoImpl!(Preferences);
// create session factory
Dialect dialect = new MySQLDialect();
SessionFactory factory = new SessionFactoryImpl(schema, dialect,
ds);
scope(exit) factory.close();
auto conn = ds.getConnection();
scope(exit) conn.close();
// create session
Session sess = factory.openSession();
scope(exit) sess.close();
Query q = sess.createQuery("select p from Preferences p");
Preferences[] list = q.list!Preferences();
return 0;
}
The method below uses ddbc.
int main(string[] args) {
string url =
"mysql://localhost:3306/test?user=test,password=test";
// creating Connection
auto conn = createConnection(url);
scope(exit) conn.close();
// creating Statement
auto stmt = conn.createStatement();
scope(exit) stmt.close();
// reading DB
auto rs = stmt.executeQuery("SELECT * FROM preferences_wm
ORDER BY id");
writeln(rs.getFetchSize());
return 0;
}
This is the error.
Running ./bin/hibernated-test
Program exited with code -11
Full exception:
object.Exception at source/dub/generators/build.d(530): Program
exited with code -11
----------------
/home/vagrant/old-dmd/dmd2/linux/bin64/../../src/phobos/std/exception.d:420 pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, const(char[])) [0x8d036c]
/home/vagrant/old-dmd/dmd2/linux/bin64/../../src/phobos/std/exception.d:388 pure @safe bool std.exception.enforce!(Exception, bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0x8defcd]
source/dub/generators/build.d:530 void
dub.generators.build.BuildGenerator.runTarget(dub.internal.vibecompat.inet.path.Path, const(dub.compilers.buildsettings.BuildSettings), immutable(char)[][], dub.generators.generator.GeneratorSettings) [0x97b1c9]
source/dub/generators/build.d:110 void
dub.generators.build.BuildGenerator.performPostGenerateActions(dub.generators.generator.GeneratorSettings, const(dub.generators.generator.ProjectGenerator.TargetInfo[immutable(char)[]])) [0x977541]
source/dub/generators/generator.d:118 void
dub.generators.generator.ProjectGenerator.generate(dub.generators.generator.GeneratorSettings) [0x9805a0]
source/dub/dub.d:494 void
dub.dub.Dub.generateProject(immutable(char)[],
dub.generators.generator.GeneratorSettings) [0x8918e0]
source/dub/commandline.d:789 int
dub.commandline.GenerateCommand.execute(dub.dub.Dub,
immutable(char)[][], immutable(char)[][]) [0x857579]
source/dub/commandline.d:821 int
dub.commandline.BuildCommand.execute(dub.dub.Dub,
immutable(char)[][], immutable(char)[][]) [0x857913]
source/dub/commandline.d:849 int
dub.commandline.RunCommand.execute(dub.dub.Dub,
immutable(char)[][], immutable(char)[][]) [0x857b23]
source/dub/commandline.d:239 int
dub.commandline.runDubCommandLine(immutable(char)[][]) [0x853647]
source/app.d:14 _Dmain [0x84fc27]
More information about the Digitalmars-d-learn
mailing list