1 /*
2  * Copyright (C) 2008 - 2011 Vivien Malerba <malerba@gnome-db.org>
3  * Copyright (C) 2010 David King <davidk@openismus.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA  02110-1301, USA.
19  */
20 
21 #include "GdaJConnection.h"
22 #include "jni-wrapper.h"
23 
24 JniWrapperMethod *GdaJConnection__close = NULL;
25 JniWrapperMethod *GdaJConnection__getServerVersion = NULL;
26 JniWrapperMethod *GdaJConnection__prepareStatement = NULL;
27 JniWrapperMethod *GdaJConnection__executeDirectSQL = NULL;
28 
29 JniWrapperMethod *GdaJConnection__begin = NULL;
30 JniWrapperMethod *GdaJConnection__rollback = NULL;
31 JniWrapperMethod *GdaJConnection__commit = NULL;
32 JniWrapperMethod *GdaJConnection__addSavepoint = NULL;
33 JniWrapperMethod *GdaJConnection__rollbackSavepoint = NULL;
34 JniWrapperMethod *GdaJConnection__releaseSavepoint = NULL;
35 
36 JniWrapperMethod *GdaJConnection__getJMeta = NULL;
37 
38 JNIEXPORT void
Java_GdaJConnection_initIDs(JNIEnv * env,jclass klass)39 JNICALL Java_GdaJConnection_initIDs (JNIEnv *env, jclass klass)
40 {
41 	gsize i;
42 	typedef struct {
43 		const gchar       *name;
44 		const gchar       *sig;
45 		gboolean           is_static;
46 		JniWrapperMethod **symbol;
47 	} MethodSignature;
48 
49 	MethodSignature methods[] = {
50 		{"close", "()V", FALSE, &GdaJConnection__close},
51 		{"getServerVersion", "()Ljava/lang/String;", FALSE, &GdaJConnection__getServerVersion},
52 		{"prepareStatement", "(Ljava/lang/String;)LGdaJPStmt;", FALSE, &GdaJConnection__prepareStatement},
53 		{"executeDirectSQL", "(Ljava/lang/String;)LGdaJResultSet;", FALSE, &GdaJConnection__executeDirectSQL},
54 		{"begin", "()V", FALSE, &GdaJConnection__begin},
55 		{"rollback", "()V", FALSE, &GdaJConnection__rollback},
56 		{"commit", "()V", FALSE, &GdaJConnection__commit},
57 		{"addSavepoint", "(Ljava/lang/String;)V", FALSE, &GdaJConnection__addSavepoint},
58 		{"rollbackSavepoint", "(Ljava/lang/String;)V", FALSE, &GdaJConnection__rollbackSavepoint},
59 		{"releaseSavepoint", "(Ljava/lang/String;)V", FALSE, &GdaJConnection__releaseSavepoint},
60 
61 		{"getJMeta", "()LGdaJMeta;", FALSE, &GdaJConnection__getJMeta}
62 	};
63 
64 	for (i = 0; i < sizeof (methods) / sizeof (MethodSignature); i++) {
65 		MethodSignature *m = & (methods [i]);
66 		*(m->symbol) = jni_wrapper_method_create (env, klass, m->name, m->sig, m->is_static, NULL);
67 		if (!*(m->symbol))
68 			g_error ("Can't find method: %s.%s", "GdaJConnection", m->name);
69 	}
70 }
71