vendredi 27 mars 2020

Unable to connect to MariaDB (java)

Having difficulty connecting to my local mariaDB server. Everything seems to be in order but I'm getting a few odd exceptions when I try to access it. My only guess is the statement "property file 'mariadb.properties' not found in the classpath". This might be a red herring, but it's my best assumption. There's a file called mariadb.properties in the mariadb.jar file but it doesn't have much in it.

Any help would be ever so greatly appreciated, thank you!

public Drugs() {
    final String JDBC_DRIVER = "org.mariadb.jdbc.Driver";
    final String DB_URL = 
        "jdbc:mariadb://localhost:3306/drug_dosage";

    final String USER = "root";
    final String PASS = "XXXXXXXXXXXX";

    Connection conn = null;
    Statement stmt = null;

    try {
            Class.forName(JDBC_DRIVER);
            System.out.println("INIT\n");

            //conn = DriverManager.getConnection(DB_URL, USER, 
                PASS);
            conn = 
                DriverManager.getConnection(
                "jdbc:mariadb://localhost:3306/drug_dosage? 
                user=root&password=XXXXXXXXXXX");
            System.out.println("CONNECTED\n");
            stmt = conn.createStatement();

            String sql = "SELECT * FROM drugs";
            ResultSet rs = stmt.executeQuery(sql);
            System.out.println("sql: " + sql + "\n");
            while (rs.next()) {
                    System.out.println("Adding: id '" + 
                        rs.getString("id") + "' drug '" + 
                        rs.getString("drug") + "'\n");
                    add(Integer.parseInt(rs.getString("id")), 
                        rs.getString("drug"));
            }
    } catch (SQLException se) {
            System.out.println("***SQL EXCEPTION***");
            se.printStackTrace();
    } catch (Exception e) {
            System.out.println("***EXCEPTION***");
            e.printStackTrace();
    }
}

Stack Trace:
Mar 27, 2020 10:52:06 PM org.restlet.engine.connector.ServerConnectionHelper start
INFO: Starting the internal [HTTP/1.1] server on port 8182
INIT

property file 'mariadb.properties' not found in the classpath
Mar 27, 2020 10:52:10 PM org.restlet.resource.ServerResource doCatch
WARNING: Exception or error caught in server resource
Internal Server Error (500) - The server encountered an unexpected condition which prevented it from fulfilling the request
    at org.restlet.resource.ServerResource.doHandle(ServerResource.java:517)
    at org.restlet.resource.ServerResource.get(ServerResource.java:707)
    at org.restlet.resource.ServerResource.doHandle(ServerResource.java:589)
    at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:649)
    at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:348)
    at org.restlet.resource.ServerResource.handle(ServerResource.java:952)
    at org.restlet.resource.Finder.handle(Finder.java:246)
    at org.restlet.routing.Filter.doHandle(Filter.java:159)
    at org.restlet.routing.Filter.handle(Filter.java:206)
    at org.restlet.routing.Router.doHandle(Router.java:431)
    at org.restlet.routing.Router.handle(Router.java:648)
    at org.restlet.routing.Filter.doHandle(Filter.java:159)
    at org.restlet.routing.Filter.handle(Filter.java:206)
    at org.restlet.routing.Filter.doHandle(Filter.java:159)
    at org.restlet.routing.Filter.handle(Filter.java:206)
    at org.restlet.routing.Filter.doHandle(Filter.java:159)
    at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:155)
    at org.restlet.routing.Filter.handle(Filter.java:206)
    at org.restlet.routing.Filter.doHandle(Filter.java:159)
    at org.restlet.routing.Filter.handle(Filter.java:206)
    at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:211)
    at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:84)
    at org.restlet.Application.handle(Application.java:381)
    at org.restlet.routing.Filter.doHandle(Filter.java:159)
    at org.restlet.routing.Filter.handle(Filter.java:206)
    at org.restlet.routing.Router.doHandle(Router.java:431)
    at org.restlet.routing.Router.handle(Router.java:648)
    at org.restlet.routing.Filter.doHandle(Filter.java:159)
    at org.restlet.routing.Filter.handle(Filter.java:206)
    at org.restlet.routing.Router.doHandle(Router.java:431)
    at org.restlet.routing.Router.handle(Router.java:648)
    at org.restlet.routing.Filter.doHandle(Filter.java:159)
    at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:155)
    at org.restlet.routing.Filter.handle(Filter.java:206)
    at org.restlet.routing.Filter.doHandle(Filter.java:159)
    at org.restlet.routing.Filter.handle(Filter.java:206)
    at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:211)
    at org.restlet.Component.handle(Component.java:392)
    at org.restlet.Server.handle(Server.java:516)
    at org.restlet.engine.connector.ServerConnectionHelper.handle(ServerConnectionHelper.java:255)
    at org.restlet.engine.connector.ServerConnectionHelper.doHandleInbound(ServerConnectionHelper.java:186)
    at org.restlet.engine.connector.BaseHelper$2.run(BaseHelper.java:593)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ExceptionInInitializerError
    at org.mariadb.jdbc.internal.com.send.SendHandshakeResponsePacket.writeConnectAttributes(SendHandshakeResponsePacket.java:202)
    at org.mariadb.jdbc.internal.com.send.SendHandshakeResponsePacket.send(SendHandshakeResponsePacket.java:187)
    at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.authenticationHandler(AbstractConnectProtocol.java:684)
    at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createConnection(AbstractConnectProtocol.java:546)
    at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1341)
    at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:634)
    at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:150)
    at org.mariadb.jdbc.Driver.connect(Driver.java:89)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:270)
    at drugs.Drugs.<init>(Drugs.java:23)
    at drugs.PlainResource.toPlain(PlainResource.java:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.restlet.resource.ServerResource.doHandle(ServerResource.java:506)
    ... 44 more
Caused by: java.lang.NullPointerException
    at org.mariadb.jdbc.internal.util.constant.Version.<clinit>(Version.java:84)
    ... 61 more



Is it bad to integrate Firebase directly with the client (VueJs)?

I'm working on my capstone project and I've seen tutorials of people using Firebase by integrating it with VueJs and I did the same. My supervisor then told me that it was a very bad thing to do and that I should have a server side in my app that connects Firebase and Vue.

Is it because we don't want to put that code in the browser for everyone to see? Why are they so many tutorials doing it the "bad" way?




Is there any way to save survey results using SurveyJS as Json or text files?

I'm using SurveyJS to develop web survey. Currently, I was able to make the survey form I wanted to make but struggled to save the data on local computer once I have completed this survey.

Do you have any idea to save the data as json or csv files on local machine? By using the script below, I could show the result on complete page and now need to save it as file on local.

survey
    .onComplete
    .add(function (result) {
        document
            .querySelector('#surveyResult')
            .textContent = "Result JSON:\n" + JSON.stringify(result.data, null, 3);
    });

$("#surveyElement").Survey({model: survey});

Please help me this was very stressful for me :(.




Sharing text on messanger from mobile with link

I want sent dynamic msg to specific facebook page with messanger by html link (but run in mobile app ) i used https//:m.me/ link but i not found parameter for msg like whatsapp " whatsapp://send?text=" thank you for helping




Loading a different domain in my app instantaneously

I have a react app where clicking on a button, it takes to a different domain(which is also a react app).The experience is not smooth.What can I do apart from dns-prefetch and preconnect to load the different website instantaneously.Can I somehow use service worker to load the dynamic resources in that website as well or do something else to make the experience smoother?




CORS header problem while loading mask image [duplicate]

I have been trying to achieve a single tone monochromic image and I think the way to do this is by masking. The images are logos which i need in a blue shade. I have converted my image into Gray scale and applied alpha masking through css. Here is the Code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Masking</title>
</head>
<body style="background-color: #0041b2">
<img class="" src="blue.svg"
     alt="Masked image" style="mask-image: url(https://storage.googleapis.com/alt-assets/media-houses/lawctopus.png);
  mask-mode: alpha;
  mask-repeat: no-repeat;
  mask-size: 80%;">
</body>
</html>

This way works on some image url but in my case I have been getting this error on the console screen.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://storage.googleapis.com/alt-assets/media-houses/lawctopus.png. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Can anyone please help me with the solution of this particular or there is some other way for me to achieve the task.

The last time the question was marked closed without a right answer. Reposting it in some hope this time. Thank you in advance.




SQL CODE is not working On my Delete link i have set my SQL correctly

So this is my delete link

<?php                       
    while ($res = $result->fetch_assoc()): ?>
<tr>
         <td><?php echo $res['ENo']; ?></td>
         <td><?php echo $res['Lastname']; ?></td>
         <td><?php echo $res['Firstname']; ?></td>
         <td><?php echo $res['MI']; ?></td>
         <td><?php echo $res['Address']; ?></td>
         <td><?php echo $res['Gender']; ?></td>
         <td><?php echo $res['MobileNo']; ?></td>
         <td><?php echo $res['Position']; ?></td>
         <td>
            <a href="function.php?delete=<?php echo $res['ENo']; ?>" class="danger">Delete</a>
         </td>
</tr>
<?php endwhile; ?>

and this is my SQL query

if (isset($_GET['delete']))
{
    $id = $_GET['delete'];

    $d = $mysqli_query($db,"DELETE FROM `tbllist` WHERE ENo = $id") or die($mysqli->error());

    if($d){
    header("location:index.php");
    }
}

it seems ok in code but its not deleting the data in the database please help its my project for my programming subject in school