How to Connect MS ACCESS to Android Apps - java

thanks before i have a problem with my project, my project are make apps in android then the Apps can connect to database in my company but this isn't connect
This is my script
package mas.ganteng;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* #author Mas Ganteng Indonesia
*/
public class ConnectedAccessActivity {
Connection conn;
String url="jdbc:odbc:JavaMsAccess";
String user="";
String pass="";
public Connection getConnection(){
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection(url,user,pass);
System.out.println("Connected!!!");
} catch (SQLException ex) {
Logger.getLogger(ConnectedAccessActivity.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(ConnectedAccessActivity.class.getName()).log(Level.SEVERE, null, ex);
}
return conn;
}
public static void main(String [] args){
ConnectedAccessActivity acc=new ConnectedAccessActivity();
acc.getConnection();
}
}
and it's the console in eclipse
Invalid layout of java.lang.String at value
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (javaClasses.cpp:124), pid=3848, tid=3876
# fatal error: Invalid layout of preloaded class
#
# JRE version: (8.0-b104) (build )
# Java VM: Java HotSpot(TM) Client VM (25.0-b46 mixed mode windows-x86 )
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\My Android\ConnectedAccess\hs_err_pid3848.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
Can you help me about this bug?????

Invalid layout of java.lang.String at value
You're trying to run an Android app as a regular Java program. Run Android apps on an Android emulator or an actual device.
The code looks like it's just a regular Java program. You should remove the Android libraries from it to be able to run it as Java.

Related

lwjgl glfwCreateWindow causes crash

I'm trying to code an opengl renderer with lwjgl. To open the window, I'm using glfw. However, when I call glfwCreateWindow, it crashes with this error:
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0x00007fff2d732924, pid=64615, tid=775
JRE version: Java(TM) SE Runtime Environment (14.0.2+12) (build 14.0.2+12-46)
Java VM: Java HotSpot(TM) 64-Bit Server VM (14.0.2+12-46, mixed mode, sharing, tiered, compressed oops, g1 gc, bsd-amd64)
Problematic frame:
C [HIToolbox+0x27924] _ZNK22THIThemeTextInfoFinder10GetOptionsEv+0x8
No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
An error report file with more information is saved as:
/Users/vic/eclipse-workspace/Engine/hs_err_pid64615.log
If you would like to submit a bug report, please visit:
https://bugreport.java.com/bugreport/crash.jsp
Here is my code:
package main;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWVidMode;
public class Main {
public static void main(String[] args) {
if(!GLFW.glfwInit()) {
System.err.println("Failed to initialize glfw");
System.exit(-1);
}
GLFW.glfwDefaultWindowHints();
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE);
long window = GLFW.glfwCreateWindow(640, 480, "My window", 0, 0);
if(window == 0) {
System.err.println("Failed to create window");
System.exit(-1);
}
GLFWVidMode videoMode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
GLFW.glfwSetWindowPos(window, (videoMode.width() - 640) / 2, (videoMode.height() - 480) / 2);
GLFW.glfwShowWindow(window);
while(!GLFW.glfwWindowShouldClose(window)) {
GLFW.glfwPollEvents();
}
GLFW.glfwTerminate();
}
}
I'm using mac and eclipse.
Thanks!
The solution is to add -XstartOnFirstThread to the JVM arguments.

Tesseract Fatal error encountered!" == NULL:Error:Assert failed:in file globaloc.cpp, line 75

1 - I downloaded tesdata on the git hub https://github.com/tesseract-ocr/tessdata
2 - Extract the folder and passed the path to the Tesseract class
3 - When running the application the following error is displayed
Extract the folder and passed the path to the Tesseract class
When running the application the following error is displayed
Code snippet executed
public class TesseractOcrTest {
private final String tesseractPath = "/home/tessdata/";
#Test
public void shouldReturnTrueIfRunOcrEquals() throws Exception {
String result = new TesseractOcr(tesseractPath).runOcr("bw_HighResolution_en.jpeg").trim();
assertEquals(
"Optical Character Recognition in Java\nis made easy with the help of Tesseract", result);
}
}
Error
Error: Illegal Parameter specification!
"Fatal error encountered!" == NULL:Error:Assert failed:in file globaloc.cpp, line 75
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f52a582d69b, pid=8957, tid=8966
#
# JRE version: OpenJDK Runtime Environment (11.0.7+10) (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)
# Java VM: OpenJDK 64-Bit Server VM (11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C [libtesseract.so.4+0x25969b] ERRCODE::error(char const*, TessErrorLogCode, char const*, ...) const+0x16b
Note: When I change the path from tesdata to the OS installation path (private final String tesseractPath = "/usr/share/tesseract-ocr/4.00/tessdata/";) I can do it perfectly. It just doesn't work if I point to the tesdata downloaded from the git hub.
What am I doing wrong? When downloaded from github do you need to do any more configuration?
You've probably used incompatible language data. For the current Tesseract verion, use tessdata_best or tessdata_fast, which comes with Linux distros. (You can verify by checking the file size.)
https://github.com/tesseract-ocr
Make sure you have installed only one version of tesseract
Fist check with version of tesseract you used (installed). Use the latest version (4.x or 5 alpha)
Test OCR with tesseract executable instead of wrapper - it can provide more information for finding problem.

Java add PostgreSQL Driver to Class Path

I have a script that I would like to use to interface with a PostgreSQL database but I'm struggling a bit to include the driver when executing.
The Java code is very basic at the moment
import java.sql.*;
import java.util.*;
public class l_connect {
public static void main(String[] args) {
try {
Class.forName("org.postgresql.Driver");
} catch(Exception log) {
System.out.println(log);
}
}
}
If I execute this
# java l_connect
it does what I expect it to; outputs the exception log that it can't find the driver
I downloaded the postgresql driver and placed it in a directory in my project and then tried to execute it
# java -cp ".;../assets/postgresql-9.4-1202.jdbc4.jar" l_connect
and I get the error
# Error: Could not find or load main class l_connect
Why would this be happening? Is my usage of java -cp not correct?
UPDATE
I forgot to mention that my system is Fedora 22 Linux and I am not using an IDE I am using the terminal
May be this would help some one.
export CLASSPATH=/myapp1.jar:/myapp2.jar

sqljdbc_auth.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform

I am trying to connect to SQL Server 2008 from JAVA code using JDBC sql server with IntegratedSecurity to use Windows Authentication.
SQL authentication worked fine with the code but when I use IntegratedSecurity for Windows Authentication, I am facing sql driver issues. I have provided the brief scenario below.
Java Code
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Sqlselection
{
public static void main(String[] args)
{
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("This programe runs on "+ System.getProperty("java.version"));
String url="jdbc:sqlserver://*****\\*****;integratedSecurity=true";
//Masked Server name & DB name
Connection con = DriverManager.getConnection(url);
Statement s1 = con.createStatement();
ResultSet rs = s1.executeQuery("SELECT count(1) myrecords FROM dbo.mytable");
String[] result = new String[20];
if(rs!=null){
while (rs.next()){
for(int i = 0; i <result.length ;i++)
{
for(int j = 0; j <result.length;j++)
{
result[j]=rs.getString(i);
System.out.println(result[j]);
}
}
}
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
Error while running the code
WARNING: Failed to load the sqljdbc_auth.dll cause : E:\POC\OMSChecker\sqljdbc_auth.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform
*com.microsoft.sqlserver.jdbc.SQLServerException:* This driver is not configured for integrated authentication. ClientConnectionId:27af9d19-d144-47be-b9cf-bf646ed9bb3f
Issue root cause
sqljdbc_auth.dll is not compatible with current platform.
System properties
C:\Users>java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
Eclipse properties
launcher: win32.x86_64_1.1.200.v20120913-144807
Used dll: E:\sqljdbc_2.0.1803.100_enu.exe\sqljdbc_2.0\enu\auth\x64\sqljdbc_auth.dll
Added External Jar: sqljdbc4.jar
Native library location: "E:\sqljdbc_2.0.1803.100_enu.exe\sqljdbc_2.0\enu\auth\x64\"
Notes
Can someone kindly help me with the fix. I am new to JAVA coding and I have tried all the solutions given for similar kind of posts.
Finally found the solution myself by re-installing Windows OS.
Used the same code above with sqljdbc4.jar & below VM argument
-Djava.library.path=E:\sqljdbc_4.0\enu\auth\x86\
I was able to connect successfully.

Bluetooth server application using java WTK 2.5.2 crashes on launch

For the last few days, I've been developing an Android application which goal is to use the touch screen to move the cursor on my computer.
I've first implemented the communication between the mobile phone and my computer using WiFi. Everything is ok but I'd like to be able to use bluetooth.
On the phone side, everything is simple and easy. What I am not able to achieve is the bluetooth server.
I've downloaded and (painfully) installed the Java Wireless Toolkit 2.5.2 and the JavaSE jdk.
For now my code is very simple and looks like this :
import java.io.IOException;
import javax.bluetooth.*;
import javax.microedition.io.*;
public class BluetoothServer extends Thread {
//private static LocalDevice localDevice;
static LocalDevice localDevice;
DiscoveryAgent agent;
//start server
private StreamConnection startServer() throws IOException{
System.loadLibrary("zayit");
//Create a UUID for SPP
UUID uuid = new UUID(0x1101);
//Create the servicve url
String connectionString = "btspp://localhost:" + uuid +";name=SampleSPPServer";
//open server url
StreamConnectionNotifier streamConnNotifier = (StreamConnectionNotifier)Connector.open( connectionString );
//Wait for client connection
System.out.println("\nServer Started. Waiting for clients to connect...");
StreamConnection connection = streamConnNotifier.acceptAndOpen();
return connection;
}
}
I've added external jars to get the import for javax.bluetooth and javax.microedition.
The project builds normally but When I launch it, it crashes with following error :
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0xb27d6400, pid=25778, tid=2999303024
#
# JRE version: 6.0_24-b07
# Java VM: Java HotSpot(TM) Server VM (19.1-b02 mixed mode linux-x86 )
# Problematic frame:
# C [libzayit.so+0x23e400] kvm_resetOperandStack+0x8
#
# An error report file with more information is saved as:
# /home/ixm/workspace/RemoteControlServer/hs_err_pid25778.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
Without the System.loadLibrary(), I got following error:
Exception in thread "Thread-1" java.lang.UnsatisfiedLinkError: javax.microedition.io.Connector.isNetworkMonitorActive()Z
at javax.microedition.io.Connector.isNetworkMonitorActive(Native Method)
at javax.microedition.io.Connector.<clinit>(Connector.java:153)
at BluetoothServer.startServer(BluetoothServer.java:20)
at BluetoothServer.run(BluetoothServer.java:43)
I have no clue what I should do or try. I did not find anything helpful on the internet.
Can someone help me? Maybe the real question, is: "Is it possible to develop a Java application (for a computer) that use bluetooth?"
Thank you very much!
Best regards,
ixM
I've juste noticed that I installed the wrong version of Java (SE instead of ME). I will not try to install the right one since it is designed for mobile devices.
Instead, I will give it a shot with bluecove. I did not investigate that way before because I thought it was a python library for windows. Apparently, this is not the case and I was blind or stupid at the time I read the project page for the first time.
Sorry

Categories